What is the version of TF for read the mobilenet_v2 checkpoint
My version is TF 1.4.1
However, Unable to read the mobilenet_v2 checkpoint
I met the problem on TensorFlow 1.4, too.
I run the following code:
saver = tf.train.Saver(var_list=gvars)
saver.restore(sess, 'mobilenet_v2_1.4_224.ckpt')
I get the following error:
DataLossError (see above for traceback): Unable to read file (mobilenet_v2_1.4_224.ckpt.index). Perhaps the file is corrupt or was produced by a newer version of TensorFlow with format changes (failed to seek to header entry): corrupted compressed block contents
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT32], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
+1
+1. I am trying to training the whole mobilenet_v2 rather than re-tuning the checkpoint.
I am getting error:
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [3,3,3,32] rhs shape= [3,3,3,48]
Tensorflow 1.7
Params:
--checkpoint_exclude_scopes=MobilenetV2/Logits
--trainable_scopes=MobilenetV2/Logits
+1
cannot load mobilenet_v2_1.4 but can load mobilenet_v2_1.0, seems like 1.4 ckpt does not match the architecture of mobilenet_v2.py in the repo. maybe it has more conv channels, need to investigate mobilenet_v2_1.4's ckpt.
+1
when I want to finetune mobilenet_v2_1.4_224_imageNet_pretrained on voc_aug, I got error as below:
INFO:tensorflow:Error reported to Coordinator:
[[Node: save/Assign_55 = Assign[T=DT_FLOAT, _class=["loc:@MobilenetV2/expanded_conv_11/project/BatchNorm/beta"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](MobilenetV2/expanded_conv_11/project/BatchNorm/beta, save/RestoreV2:55)]]
@raninbowlalala You should set the num_classes=None when you calling the model mobilenet_v2, and then add a additionally fully_connected layer with you specified num_classes.
In mobilenet_v2.py, depth_multiplier=1 for both mobilenet and mobilenet_base, you should change that to 1.4
@slim.add_arg_scope
def mobilenet_base(input_tensor, depth_multiplier=1.4, **kwargs):
"""Creates base of the mobilenet (no pooling and no logits) ."""
return mobilenet(input_tensor,
depth_multiplier=depth_multiplier,
base_only=True, **kwargs)
@slim.add_arg_scope
def mobilenet(input_tensor,
num_classes=1001,
depth_multiplier=1.4,
scope='MobilenetV2',
conv_defs=None,
finegrain_classification_mode=False,
min_depth=None,
divisible_by=None,
**kwargs):
tf1.4.0 Unable to read file (mobilenet_v2_1.4_224.ckpt.index). Perhaps the file is corrupt or was produced by a newer version of TensorFlow with format changes (failed to seek to header entry): corrupted compressed block contents
+1
I also got the following error info when loading mobilenet_v2_1.4_224.ckpt.index
tensorflow/core/framework/op_kernel.cc:1192] Data loss: Unable to read
file(pretrained/mobilenetv2/mobilenet_v2_1.4_224.ckpt.index). Perhaps the file
is corrupt or was produced by newer version of TensorFlow with format changes
(failed to seek to header entry): corrupted compressed block contents
I also changed the parameter depth_multiplier=1 to 1.4 in mobilenet_v2.py for both mobilenet and mobilenet_base, still no uses.
For previous tensor mismatch issue, I think changing the parameter works since I didn't see anymore, but the above corrupted error still remains and I think it's related to the file format or tensorflow version
I got the same error when loading mobilenet_v2_1.4_224.ckpt.index
to deeplab v3+, using mobilenet_v2 as backe bone. Inspired by @sid6641, i searched paramater depth_multiplier=1
and modified it to 1.4, but it didn't work , like @deercoder. I think the reason is old ckpt doesn't match the current one, I fix it by using mobilenet_v2_1.0_224
.
@deercoder loading mobilenet_v2_1.4_224.ckpt instead of loading mobilenet_v2_1.4_224.ckpt.index
@NxG1GnX mobilenet_v2_1.0_224??? Mine is mobilenet_v2_1.0_224.ckpt, which is the prefix of data/meta/index
I still try to use mobilenet_v2_1.4_224.ckpt or mobilenet_v2_1.0_224.ckpt , but all fail.My tensorflow version is 1.4.0 ,maybe the version is too low , but I don't want to update. How to solve the question?
error information is:
DataLossError (see above for traceback): Unable to read file (/home/hanlab/zhangpeng/mobilenetV2/1.0/mobilenet_v2_1.0_224.ckpt.index). Perhaps the file is corrupt or was produced by a newer version of TensorFlow with format changes (failed to seek to header entry): corrupted compressed block contents
[[Node: save/RestoreV2_4 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_4/tensor_names, save/RestoreV2_4/shape_and_slices)]]
@NxG1GnX Are you sure that you can use mobilenet_v2_1.0_224.ckpt ?What's your tensorflow version?
In mobilenet_v2.py, depth_multiplier=1 for both mobilenet and mobilenet_base, you should change that to 1.4
@slim.add_arg_scope def mobilenet_base(input_tensor, depth_multiplier=1.4, **kwargs): """Creates base of the mobilenet (no pooling and no logits) .""" return mobilenet(input_tensor, depth_multiplier=depth_multiplier, base_only=True, **kwargs)
@slim.add_arg_scope def mobilenet(input_tensor, num_classes=1001, depth_multiplier=1.4, scope='MobilenetV2', conv_defs=None, finegrain_classification_mode=False, min_depth=None, divisible_by=None, **kwargs):
In practice, I found that the divisible_by
parameter is also important.
You can try to set
divisible_by=8
if you failed to restore the ckpt.
This setting makes the number of channels to be divisible by 8.
And it is consistent with the number of channels in the provided ckpt.
https://github.com/tensorflow/models/tree/master/research/slim/nets/mobilenet
Hi There,
We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing.
If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.
Most helpful comment
In mobilenet_v2.py, depth_multiplier=1 for both mobilenet and mobilenet_base, you should change that to 1.4