models icon indicating copy to clipboard operation
models copied to clipboard

Find a bug in when initializing with mobilenet v2 checkpoints

Open Shenghsin opened this issue 8 years ago • 6 comments

Hi there: I try to retrain the deeplab model with mobilenet V2 and set the "depth_multiplier = 0.5", when initializing the model with the checkpoints pretrained on ImageNet provided in https://github.com/tensorflow/models/tree/master/research/slim/nets/mobilenet
"mobilenet_v2_0.5_224". An error " InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [12] rhs shape= [16] [[Node: save/Assign_26 = Assign[T=DT_FLOAT, _class=["loc:@MobilenetV2/expanded_conv_1/project/BatchNorm/gamma"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](MobilenetV2/expanded_conv_1/project/BatchNorm/gamma, save/RestoreV2_26)]]" is reported. After investigation, i found this error is result in a bug in "deep/core/feature_extractor.py", line 65: "divisible_by=8 if depth_multiplier == 1.0 else 1" , should be "divisible_by=8 if depth_multiplier != 1.0 else 1"

Shenghsin avatar Oct 12 '18 02:10 Shenghsin

Thanks for reporting the issue, Shenghsin. Yes, there is minor difference between the original mobilenetv2-depth_multiplier = 0.5 and the version we are using. If you would like to retrain deeplab, I would suggest two options:

  1. You change the code as you suggested and initialize from the provided ImageNet pretrained checkpoint under slim/nets/mobilenet folder.
  2. You could use our setting to train the "modified" mobilenetv2 depth-multiplier = 0.5 on ImageNet.

We currently do not have any plan to fix the difference since our MobileNetv2 depth-multplier=0.5 checkpoints are all trained w.r.t. our setting.

Cheers,

aquariusjay avatar Oct 12 '18 04:10 aquariusjay

@aquariusjay Thanks for you reply and the extraordinarily work you have done.

Shenghsin avatar Oct 15 '18 02:10 Shenghsin

Hi Shenghsin,

You are very welcome. Happy to know that you find the model and code useful.

Cheers,

aquariusjay avatar Oct 15 '18 03:10 aquariusjay

Closing this issue since it has been resolved. Feel free to reopen if have any follow up questions. Thanks!

ymodak avatar Dec 26 '18 22:12 ymodak

Dear ymodak and aquariusjay, as for the mobilnetv2 model, if I set the depth_multiplier smaller than one, it will raise: ValueError:(Ambiguous dimension: %s" % value). It seems we can not change it. I want to know how to fix?

carolchenyx avatar Sep 15 '20 10:09 carolchenyx

Dear ymodak and aquariusjay, as for the mobilnetv2 model, if I set the depth_multiplier smaller than one, it will raise: ValueError:(Ambiguous dimension: %s" % value). It seems we can not change it. I want to know how to fix?

Hi, @carolchenyx Did you fix this problem? I encountered the same case after I changed the depth_multiplier from 1.0 to 0.5.

raise ValueError("Shapes %s and %s are incompatible" % (self, other)) ValueError: Shapes (3, 3, 3, 16) and (3, 3, 3, 32) are incompatible

04633435 avatar Jan 06 '21 23:01 04633435