我是 TensorFlow 菜鸟。我已经从 deeppose 的开源实现中训练了一个 TensorFlow 模型,现在必须针对一组新图像运行该模型。
该模型是在大小为 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 参数来自哪里。我查看了所有配置文件,似乎没有任何参数指定此配置。
解决此问题的任何帮助将不胜感激。
原文由 Pradeep Banavara 发布,翻译遵循 CC BY-SA 4.0 许可协议
尝试删除从以前的运行中保存的所有检查点。有时,当更改架构并再次运行时,TF 会从旧的检查点(但具有新的定义)获取,并且您会收到此错误。