yeephycho/nasnet-tensorflow

Freeze Graph error!

futureflsl opened this issue · 1 comments

Freeze Graph error!

I download pre-treined model nasnet-a_mobile_04_10_2017
then exceute

For mobile model

python export_inference_graph.py
--alsologtostderr
--model_name=nasnet_mobile
--output_file=./inference/nasnet_mobile_inf_graph.pb

I got nasnet_mobile_inf_graph.pb in success

now I excute
python freeze_graph.py
--input_graph=./inference/nasnet_mobile_inf_graph.pb
--input_checkpoint=./pre-trained/nasnet-a_mobile_04_10_2017/model.ckpt
--input_binary=true
--output_graph=./inference/frozen_nasnet_mobile.pb
--output_node_names=final_layer/predictions
it dosen't work!
WARNING:tensorflow:From freeze_graph.py:170: FastGFile.init (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.
WARNING:tensorflow:From freeze_graph.py:80: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
2019-10-16 17:24:11.032563: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-10-16 17:24:11.053495: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3192000000 Hz
2019-10-16 17:24:11.053846: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x55b0d915e1f0 executing computations on platform Host. Devices:
2019-10-16 17:24:11.053871: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): ,
WARNING:tensorflow:From /home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/control_flow_ops.py:3632: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
return fn(*args)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [5] rhs shape= [1001]
[[{{node save/Assign_984}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 1276, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [5] rhs shape= [1001]
[[node save/Assign_984 (defined at freeze_graph.py:128) ]]

Caused by op 'save/Assign_984', defined at:
File "freeze_graph.py", line 382, in
run_main()
File "freeze_graph.py", line 379, in run_main
app.run(main=my_main, argv=[sys.argv[0]] + unparsed)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "freeze_graph.py", line 378, in
my_main = lambda unused_args: main(unused_args, flags)
File "freeze_graph.py", line 272, in main
flags.saved_model_tags, checkpoint_version)
File "freeze_graph.py", line 254, in freeze_graph
checkpoint_version=checkpoint_version)
File "freeze_graph.py", line 128, in freeze_graph_with_def_protos
var_list=var_list, write_version=checkpoint_version)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 832, in init
self.build()
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 844, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 881, in _build
build_save=build_save, build_restore=build_restore)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 513, in _build_internal
restore_sequentially, reshape)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 354, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 73, in restore
self.op.get_shape().is_fully_defined())
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/state_ops.py", line 223, in assign
validate_shape=validate_shape)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 64, in assign
use_locking=use_locking, name=name)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1801, in init
self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [5] rhs shape= [1001]
[[node save/Assign_984 (defined at freeze_graph.py:128) ]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "freeze_graph.py", line 382, in
run_main()
File "freeze_graph.py", line 379, in run_main
app.run(main=my_main, argv=[sys.argv[0]] + unparsed)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "freeze_graph.py", line 378, in
my_main = lambda unused_args: main(unused_args, flags)
File "freeze_graph.py", line 272, in main
flags.saved_model_tags, checkpoint_version)
File "freeze_graph.py", line 254, in freeze_graph
checkpoint_version=checkpoint_version)
File "freeze_graph.py", line 129, in freeze_graph_with_def_protos
saver.restore(sess, input_checkpoint)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 1312, in restore
err, "a mismatch between the current graph and the graph")
tensorflow.python.framework.errors_impl.InvalidArgumentError: Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Assign requires shapes of both tensors to match. lhs shape= [5] rhs shape= [1001]
[[node save/Assign_984 (defined at freeze_graph.py:128) ]]

Caused by op 'save/Assign_984', defined at:
File "freeze_graph.py", line 382, in
run_main()
File "freeze_graph.py", line 379, in run_main
app.run(main=my_main, argv=[sys.argv[0]] + unparsed)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "freeze_graph.py", line 378, in
my_main = lambda unused_args: main(unused_args, flags)
File "freeze_graph.py", line 272, in main
flags.saved_model_tags, checkpoint_version)
File "freeze_graph.py", line 254, in freeze_graph
checkpoint_version=checkpoint_version)
File "freeze_graph.py", line 128, in freeze_graph_with_def_protos
var_list=var_list, write_version=checkpoint_version)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 832, in init
self.build()
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 844, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 881, in _build
build_save=build_save, build_restore=build_restore)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 513, in _build_internal
restore_sequentially, reshape)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 354, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 73, in restore
self.op.get_shape().is_fully_defined())
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/state_ops.py", line 223, in assign
validate_shape=validate_shape)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 64, in assign
use_locking=use_locking, name=name)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/home/fut/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1801, in init
self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Assign requires shapes of both tensors to match. lhs shape= [5] rhs shape= [1001]
[[node save/Assign_984 (defined at freeze_graph.py:128) ]]