系统信息: Mac OS Mojave
从(源或二进制)安装的TensorFlow: pip install tensorflow
TensorFlow版本(如果是源代码,则为github SHA): 1.12
我正在尝试将简单的卷积张量流模型转换为张量流lite。我已经有SavedModel格式的了。但是,当我尝试在保存的模型上运行convert util时,我得到:
RuntimeError: TOCO failed see console for info.
b"2018-12-30 15:40:54.449737: I tensorflow/contrib/lite/toco/import_tensorflow.cc:189] Unsupported data type in placeholder op: 2\n2018-12-30 15:40:54.450020: F tensorflow/contrib/lite/toco/import_tensorflow.cc:2137] Check failed: status.ok() Unexpected value forattribute 'T'. Expected 'DT_FLOAT'\n"
要保存模型,我要:
// model is an Estimator instance
def export(model):
model.export_saved_model("tmp/export", serving_input_receiver_fn)
和:
def serving_input_receiver_fn():
features = { 'x': tf.placeholder(shape=[1, 100, 100, 1], dtype=tf.as_dtype(np.int32)) }
return tf.estimator.export.ServingInputReceiver(features, features)
输入dtype为np.int32,因此我尝试在此处将其转换为tf类型。
我可以根据要求附上完整的模型定义。
谢谢。
答案 0 :(得分:0)
解决方案不是在占位符op本身中,而是在模型声明中。我正在使用float64输入类型。切换到float32,并在占位符中设置dtype = float32,解决了我的问题。