【发布时间】:2019-09-25 02:37:54
【问题描述】:
我正在尝试使用 TFLiteConverter 来转换我的网络。所以我先尝试了示例代码。有用。但是经过一些修改后,它会发回错误。似乎 input_array 和 output_array 必须是相同的大小。我只是不明白为什么。有人可以帮帮我吗?
我将 img from 的大小和 var 的大小从 [1,64,64,3 修改为 [1,64,3,1]
完整代码粘贴在下面enter code here
import tensorflow as tf
img = tf.placeholder(name="img", dtype=tf.float32, shape=(1, 64, 64, 1))
var = tf.get_variable("weights", dtype=tf.float32, shape=(1, 64, 3, 1))
val = tf.matmul(img,var)
out = tf.identity(val, name="out")
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(val.shape)
converter = tf.lite.TFLiteConverter.from_session(sess, [img], [out])
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)
错误消息: ValueError:维度必须相等,但对于输入形状为 [1,64,64,1]、[1,64,3,1] 的“MatMul”(操作:“BatchMatMulV2”),维度必须是 1 和 3。
【问题讨论】:
标签: tensorflow tensorflow-lite