首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >tensorflow.lite.python.convert.ConverterError?

tensorflow.lite.python.convert.ConverterError?

提问于 2022-12-28 09:48:19
回答 0关注 0查看 71

先将tensorflow2.4cpkt转为.pb模型。再将.pb模型转为.tflite时报错

File "D:\Program Files\Python\Python37\lib\site-packages\tensorflow\lite\python\convert.py", line 216, in toco_convert_protos

raise ConverterError(str(e))

tensorflow.lite.python.convert.ConverterError: <unknown>:0: error: loc("bidirectional_rnn/bw/bw/while"): 'tf.WhileRegion' op body result type tensor<1x1x256xf32> is incompatible with result type tensor<0x1x256xf32> at index 7

下面是我.pb转tflite的代码

代码语言:javascript
复制
import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()



# 把pb文件路径改成自己的pb文件路径即可
path = "../model/HTOCR.pb"

# 如果是不知道自己的模型的输入输出节点,建议用tensorboard做可视化查看计算图,计算图里有输入输出的节点名称
inputs = ["Placeholder","Placeholder_4","is_train"]
outputs = ["CTCGreedyDecoder","transpose"]

input_tensor_shape = {'Placeholder': [1, 616, 32],'Placeholder_4':[1],'is_train':[1]}
# 转换pb模型到tflite模型
converter = tf.lite.TFLiteConverter.from_frozen_graph(path, inputs, outputs,input_tensor_shape)
# converter.post_training_quantize = True

tflite_model = converter.convert()
open("../model/HTOCR.tflite", "wb").write(tflite_model)

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档