tensorpack / tensorpack

A Neural Net Training Interface on TensorFlow, with focus on speed + flexibility
Apache License 2.0
6.3k stars 1.81k forks source link

Assign requires shapes of both tensors to match. lhs shape= [1,1,4096,4096] rhs shape= [4096,4096] #827

Closed zxqcreations closed 6 years ago

zxqcreations commented 6 years ago

Hi, I've tried to build my own vgg16 with my code gennet which is used to generate CNNs. By following vgg's paper, I generated a vgg16 model by myself (use testgen.py to generate a vgg16.ckpt). But when I tried to apply it to train_faster_rcnn.sh, I met this issue:

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

I didn't edit any code gitted from this repository, and executed ./experiments/scripts/train_faster_rcnn.sh 0 pascal_voc vgg16.

When I execute inspect_checkpoint.py provided by tensorflow to inspect differences between your model and mine, I got:

  1. fc6: yours: vgg_16/fc6/weights (DT_FLOAT) [7,7,512,4096] mine: vgg_16/fc6/weights (DT_FLOAT) [25088,4096]
  2. fc7: yours: vgg_16/fc7/weights (DT_FLOAT) [1,1,4096,4096] mine: vgg_16/fc7/weights (DT_FLOAT) [4096,4096]
  3. fc8: yours: vgg_16/fc8/weights (DT_FLOAT) [1,1,4096,1000] mine: vgg_16/fc8/weights (DT_FLOAT) [4096,1000]|

there are several difference from fc6 to fc8, but I don't know how to fix it. I'd like to ask you why the shape of fc layers are different or am I wrong? emm. If you are too busy to review this difference, please ignore it.

But I know my vgg16 is not working, waiting for your kindly review.

ppwwyyxx commented 6 years ago

I don't understand your question completely but it seems like you want to know why "my model" has different shape for some weights from your models. However I don't know which of the "my model" are you talking about, and how did you obtain "my model". Could you answer these questions with more details?

zxqcreations commented 6 years ago

@ppwwyyxx Thanks for your review. Here my model is generated by gennet, its a tool to generate a CNN.

yes, differences for some weights, 'your model' is vgg16.ckpt from google drive while mine is generated by gennet.

ppwwyyxx commented 6 years ago

'your model' is vgg16.ckpt from google drive

Could you give more details? I have not put any vgg16.ckpt on google drive IIRC.

zxqcreations commented 6 years ago

@ppwwyyxx oh my god... It's all my fault...... I just clicked a wrong link.....the vgg16.ckpt is from google drive uploaded by totally an another author(endernewton). I'm so stupid and close this issue......

I'm so sorry and really thank you.