deep-camera-relocalization icon indicating copy to clipboard operation
deep-camera-relocalization copied to clipboard

Could not reload the pretrained mobilenet model

Open dyz-zju opened this issue 7 years ago • 8 comments

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"]]

dyz-zju avatar Oct 01 '17 05:10 dyz-zju

https://github.com/tensorflow/tensorflow/issues/312

https://github.com/tensorflow/tensorflow/issues/7244

futurely avatar Oct 14 '17 13:10 futurely

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

dyz-zju avatar Oct 14 '17 13:10 dyz-zju

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

ghost avatar Oct 20 '17 18:10 ghost

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)

dyz-zju avatar Oct 25 '17 12:10 dyz-zju

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'

ghost avatar Oct 25 '17 18:10 ghost

@zhuoruiyang from tensorflow.python import pywrap_tensorflow

dyz-zju avatar Oct 26 '17 02:10 dyz-zju

@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 avatar Oct 26 '17 17:10 ghost

@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.

ghost avatar Nov 01 '17 18:11 ghost