Tensorflow tutorial "How to Retrain": error when saving the model

487 views
Skip to first unread message

mostaf...@gmail.com

unread,
Mar 5, 2016, 1:20:00 AM3/5/16
to Discuss
hello,


I am trying to run the tutorial 'How to Retrain Inception's Final Layer for New Categories'
available here: https://www.tensorflow.org/versions/master/how_tos/image_retraining/index.html


I do not use Bazel, I just do: 

python retrain.py --image_dir ~/flower_photos


Everything runs smoothly, until I get this error:

Final test accuracy = 91.6%
Traceback (most recent call last):
File "retrain.py", line 829, in <module>
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/default/_app.py", line 30, in run
sys.exit(main(sys.argv))
File "retrain.py", line 820, in main
output_graph_def = graph_util.convert_variables_to_constants(
AttributeError: 'module' object has no attribute 'convert_variables_to_constants'


The problematic portion of the code is:


  # Write out the trained graph and labels with the weights stored as constants.
  output_graph_def = graph_util.convert_variables_to_constants(
      sess, graph.as_graph_def(), [FLAGS.final_tensor_name])
  with gfile.FastGFile(FLAGS.output_graph, 'wb') as f:
    f.write(output_graph_def.SerializeToString())
  with gfile.FastGFile(FLAGS.output_labels, 'w') as f:
    f.write('\n'.join(image_lists.keys()) + '\n')



What should I do?

Pete Warden

unread,
Mar 7, 2016, 11:20:19 AM3/7/16
to mostaf...@gmail.com, Discuss
Hi,
     sorry to see you're hitting problems! The Bazel build process helps set up the dependency paths for things like graph_util, so that's the supported path for this. Looking at your error, I'm guessing you have an older pip-installed version of TensorFlow, where the graph_util namespace didn't include that function, which was introduced after 0.7.1.

Pete

--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/33440102-088d-4de9-92e0-e2b39fd1db4c%40tensorflow.org.

Reply all
Reply to author
Forward
0 new messages