我是一个TensorFlow noob。我已经从开源的deeppose实现中训练了一个TensorFlow模型,并且现在必须针对一组新的图像运行该模型。Tensorflow Assign要求两个张量的形状相匹配。 lhs shape = [20] rhs shape = [48]
该模型在尺寸为100 * 100
的图像上进行了训练,因此我将这组新图像调整为相同尺寸。我有149
新图像来运行该模型。当我运行模型时,出现以下错误。
InvalidArgumentError (see above for traceback): Assign requires shapes
of both tensors to match. lhs shape= [20] rhs shape= [48]
在生产线
saver = tf.train.Saver(tf.all_variables())
我怀疑训练模型大小和测试图像大小不匹配。我不清楚如何解决这个问题。我打印出tf.all_variables()
调用的变量列表。这里是
Tensor("Placeholder:0", shape=(128, 100, 100, 3), dtype=float32)
(11, 11, 3, 20)
conv1/weights:0
(20,)
conv1/biases:0
(5, 5, 20, 35)
conv2/weights:0
(35,)
conv2/biases:0
(3, 3, 35, 50)
conv4/weights:0
(50,)
conv4/biases:0
(3, 3, 50, 75)
conv5/weights:0
(75,)
conv5/biases:0
(300, 1024)
local1/weights:0
(1024,)
local1/biases:0
(1024, 1024)
local2/weights:0
(1024,)
local2/biases:0
(1024, 0)
softmax_linear/weights:0
(0,)
softmax_linear/biases:0
我不确定RHS参数来自哪里。我已经看过所有的配置文件,并且似乎没有指定此配置的任何参数。
任何帮助解决此问题将不胜感激。
尝试'saver = tf.train.Saver(tf.all_variables(),reshape = True)' – yuefengz
你能展示更大的堆栈跟踪吗? – sygi
@Fake - 重塑不起作用,但我解决了这个问题。感谢队友 –