5

I am using TensorFlow 1.7 with Python 3.6.5 on a Mac with High Sierra.

I have trained my first MNIST model, so I basically have

  • a graph.pbtxt file with the CNN graph structure
  • some model.ckpt-21000 files (.meta, .index .data)

I tried to freeze the graph using the command line freeze_graph command on my bash:

freeze_graph
--input_graph=/…/graph.pbtxt
--input_checkpoint=/…/model.ckpt-21000
--input_binary=false
--output_graph=/…/frozen_mnist.pb
--output_node_names=softmax_tensor

But I got this error:

Traceback (most recent call last):  
File “/usr/local/bin/freeze_graph”, line 11, in <module>  
sys.exit(main())  
TypeError: main() missing 1 required positional argument: ‘unused_args’

I am not really sure what I am missing there. I am quite sure I am using the correct syntax.

Andrea Rossi
  • 981
  • 1
  • 10
  • 23

1 Answers1

9

I have found a workaround to freeze my graph. I am posting it here so if anyone encounters the same issue, they can use this.

Instead of

freeze_graph
--input_graph=/…/graph.pbtxt
--input_checkpoint=/…/model.ckpt-21000
--input_binary=false
--output_graph=/…/frozen_mnist.pb
--output_node_names=softmax_tensor

Use

python3 -m tensorflow.python.tools.freeze_graph
--input_graph=/…/graph.pbtxt
--input_checkpoint=/…/model.ckpt-21000
--input_binary=false
--output_graph=/…/frozen_mnist.pb
--output_node_names=softmax_tensor

So basically instead of the command freeze_graph I just used python3 -m tensorflow.python.tools.freeze_graph.

Still I would really like to understand why the command line did not work for me :(

Andrea Rossi
  • 981
  • 1
  • 10
  • 23