Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow Assign requires shapes of both tensors to match. lhs shape= [20] rhs shape= [48]

I am a TensorFlow noob. I have trained a TensorFlow model from the open source implementation of deeppose and have to now run the model against a new set of images.

The model was trained on images of size 100 * 100 so I have resized the new set of images to the same size. I have 149 new images to run the model against. When I run the model, I get the following error.

InvalidArgumentError (see above for traceback): Assign requires shapes
of both tensors to match. lhs shape= [20] rhs shape= [48]

At the line

saver = tf.train.Saver(tf.all_variables())

I suspect the trained model size and the test image sizes are not matching. I am not clear how to fix this issue. I printed out the list of variables from the tf.all_variables() call. Here it is

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

I am not sure where the RHS parameter is coming from. I've looked at all config files and there doesn't seem to be any parameter specifying this config.

Any help in resolving this will be greatly appreciated.

like image 684
Pradeep Banavara Avatar asked Nov 15 '16 04:11

Pradeep Banavara


1 Answers

Try deleting any checkpoints that were saved from previous runs. Sometimes when changing the architecture and running again, TF will pick up from the old checkpoint (but with new definition), and you get this error.

like image 148
maurice Avatar answered Sep 18 '22 14:09

maurice