Find a bug in when initializing with mobilenet v2 checkpoints
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"
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:
- You change the code as you suggested and initialize from the provided ImageNet pretrained checkpoint under slim/nets/mobilenet folder.
- 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 Thanks for you reply and the extraordinarily work you have done.
Hi Shenghsin,
You are very welcome. Happy to know that you find the model and code useful.
Cheers,
Closing this issue since it has been resolved. Feel free to reopen if have any follow up questions. Thanks!
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?
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