Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not reload the pretrained mobilenet model #1

Open
dyz-zju opened this issue Oct 1, 2017 · 8 comments
Open

Could not reload the pretrained mobilenet model #1

dyz-zju opened this issue Oct 1, 2017 · 8 comments

Comments

@dyz-zju
Copy link

dyz-zju commented Oct 1, 2017

NotFoundError (see above for traceback): Key MobilenetV1/Conv2d_9_pointwise/BatchNorm/beta/Adam not found in checkpoint
[[Node: save_2/RestoreV2_287 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_2/Const_0, save_2/RestoreV2_287/tensor_names, save_2/RestoreV2_287/shape_and_slices)]]
[[Node: save_2/RestoreV2_110/_1209 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_1345_save_2/RestoreV2_110", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]

@futurely
Copy link
Owner

futurely commented Oct 14, 2017

@dyz-zju
Copy link
Author

dyz-zju commented Oct 14, 2017

I have solved this problem and run normally, but have you made this network loss converged as your process?

@ghost
Copy link

ghost commented Oct 20, 2017

@dyz-zju Can you share some details regarding solving this issue? Having trouble to run it. Thanks!

@dyz-zju
Copy link
Author

dyz-zju commented Oct 25, 2017

Hi @zhuoruiyang
I changed like this:
try:
checkpoint=tf.train.latest_checkpoint(output_file)
saver.restore(sess, checkpoint)
except:
variables=tf.global_variables()
reader=pywrap_tensorflow.NewCheckpointReader(model_path)
var_keep_dic=reader.get_variables_to_shape_map()
variables_to_restore = []
for v in variables:
if v.name.split(':')[0] in var_keep_dic:
variables_to_restore.append(v)
restorer = tf.train.Saver(variables_to_restore)
restorer.restore(sess, model_path)

@ghost
Copy link

ghost commented Oct 25, 2017

Hi @dyz-zju
Thank you for your response!
Still, it doesn't work for me. The following is what I got. Do you have any ideas why it happens? Or maybe it's better if you don't mind to upload your working code? Perhaps there is somewhere else I need to make the changes to fix the issue.
Traceback (most recent call last):
File "/home/zhuorui/git/deep-camera-relocalization/run_posenet.py", line 197, in
main()
File "/home/zhuorui/git/deep-camera-relocalization/run_posenet.py", line 127, in main
var_keep_dic = reader.get_variables_to_shape_map()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 116, in
getattr = lambda self, name: _swig_getattr(self, CheckpointReader, name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 69, in _swig_getattr_nondynamic
return object.getattr(self, name)
AttributeError: type object 'object' has no attribute 'getattr'

@dyz-zju
Copy link
Author

dyz-zju commented Oct 26, 2017

@zhuoruiyang
from tensorflow.python import pywrap_tensorflow

@ghost
Copy link

ghost commented Oct 26, 2017

@dyz-zju I did make that change in my code so that I can run the piece of code you sent inside the original code. BTW, regarding pretrained model, I downloaded from the following link, which should be correct I believe. Any other thought? Thanks!
https://github.com/tensorflow/models/tree/master/research/slim

@ghost
Copy link

ghost commented Nov 1, 2017

@dyz-zju
Finally, I'm able to run it properly now. Thanks for your suggestions!
Your fix should work, I think I made a small mistake while setting the path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants