endernewton / tf-faster-rcnn

Tensorflow Faster RCNN for Object Detection
https://arxiv.org/pdf/1702.02138.pdf
MIT License
3.65k stars 1.58k forks source link

Use resnet_v2 as the basic network. InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1024] rhs shape= [2048] #379

Closed Dontfall closed 6 years ago

Dontfall commented 6 years ago

Use resnet_v2 as the basic network. When training the network, the following error occurred. Can anybody show your solutions? Please help me, thank you !!! @endernewton

:~/densecap-tensorflow$ bash scripts/dense_cap_train.sh visual_genome_1.2 resnet_v2_50 /home/xiewei/densecap-tensorflow/slim_models/resnet_v2_50.ckpt /home/xiewei/densecap-tensorflow/visual_genome 1

Caused by op u'save_1/Assign_217', defined at: File "./tools/train_net.py", line 221, in main() File "./tools/train_net.py", line 217, in main max_iters=args.max_iters) File "/home/xiewei/densecap-tensorflow/tools/../lib/dense_cap/train.py", line 485, in train_net sw.train_model(sess, max_iters) File "/home/xiewei/densecap-tensorflow/tools/../lib/dense_cap/train.py", line 325, in train_model rate, last_snapshot_iter, stepsizes, np_paths, ss_paths = self.initialize(sess) File "/home/xiewei/densecap-tensorflow/tools/../lib/dense_cap/train.py", line 236, in initialize restorer = tf.train.Saver(variables_to_restore) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1218, in init self.build() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1227, in build self._build(self._filename, build_save=True, build_restore=True) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1263, in _build build_save=build_save, build_restore=build_restore) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 751, in _build_internal restore_sequentially, reshape) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 439, in _AddRestoreOps assign_ops.append(saveable.restore(tensors, shapes)) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 160, in restore self.op.get_shape().is_fully_defined()) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/state_ops.py", line 276, in assign validate_shape=validate_shape) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_state_ops.py", line 57, in assign use_locking=use_locking, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2956, in create_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1470, 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= [1024] rhs shape= [2048] [[Node: save_1/Assign_217 = Assign[T=DT_FLOAT, _class=["loc:@resnet_v2_50/postnorm/moving_variance"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](resnet_v2_50/postnorm/moving_variance, save_1/RestoreV2_217/_9)]]

Dontfall commented 6 years ago

Use resnet_v1 as the basic network is fine.

Dontfall commented 6 years ago

@philokey please help me! thank you!

philokey commented 6 years ago

@Dontfall I also met similar problem, but I didn't solve it. Sorry, I can't help you.

Dontfall commented 6 years ago

@philokey I read other people's similar situations in endernewton/tf-faster-rcnn/issues.
I don't know what caused it. The wrong parameter in config.py caused this problem, or the model structure based on resnet_v2 caused this problem.
thank you, very much.

Macile commented 4 years ago

I also met similar problem ,Can you show your solutions? thank you very much

Qian2333 commented 3 years ago

I think this is because the weights is trained on v1,so there is some different bewteen the weights tensor