dBeker / Faster-RCNN-TensorFlow-Python3

Tensorflow Faster R-CNN for Windows/Linux and Python 3 (3.5/3.6/3.7)
MIT License
612 stars 329 forks source link

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

Closed kmust-why closed 5 years ago

kmust-why commented 6 years ago

I use my own dataset to test under windows.: tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [84] rhs shape= [28] [[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@vgg_16/bbox_pred/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](vgg_16/bbox_pred/biases, save/RestoreV2)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "E:/BaiduNetdiskDownload/FasterRcnn/Faster-RCNN-TensorFlow-Python3.5-master/demo_test.py", line 152, in saver.restore(sess, tfmodel) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 1752, in restore {self.saver_def.filename_tensor_name: save_path}) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 900, in run run_metadata_ptr) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1135, in _run feed_dict_tensor, options, run_metadata) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1316, in _do_run run_metadata) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1335, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [84] rhs shape= [28] [[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@vgg_16/bbox_pred/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](vgg_16/bbox_pred/biases, save/RestoreV2)]]

Caused by op 'save/Assign', defined at: File "E:/BaiduNetdiskDownload/FasterRcnn/Faster-RCNN-TensorFlow-Python3.5-master/demo_test.py", line 151, in saver = tf.train.Saver() File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 1284, in init self.build() File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 1296, in build self._build(self._filename, build_save=True, build_restore=True) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 1333, in _build build_save=build_save, build_restore=build_restore) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 781, in _build_internal restore_sequentially, reshape) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 422, in _AddRestoreOps assign_ops.append(saveable.restore(saveable_tensors, shapes)) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 113, in restore self.op.get_shape().is_fully_defined()) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\state_ops.py", line 219, in assign validate_shape=validate_shape) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 63, in assign use_locking=use_locking, name=name) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3414, in create_op op_def=op_def) File "D:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1740, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [84] rhs shape= [28] [[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@vgg_16/bbox_pred/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](vgg_16/bbox_pred/biases, save/RestoreV2)]]

Process finished with exit code 1

What could be the problem, thank you!

morpheusthewhite commented 5 years ago

It seems that your saved net does not match the one expected by the demo

morpheusthewhite commented 5 years ago

In https://github.com/dBeker/Faster-RCNN-TensorFlow-Python3.5/issues/38 some talked about changing the number of classes, you should check it out