0
$\begingroup$

(Warning, I'm a Tensorflow/ML noob)

I'm trying to convert and load a TensorFlow model into tensorflow.js

The model is saved:

saver.save(sess, checkpoint_path, global_step=model.global_step)

and potentially restored:

saver.restore(session, ckpt.model_checkpoint_path)

This (and similar lines) creates a directory structure:

model_tmp
  checkpoint
  model.ckpt-100.data-00000-of-00001
  model.ckpt-100.index
  model.ckpt-100.meta
  ...
  model.ckpt-500.meta

...So I should be able to convert to a JS model, right?

#TODO --output_node_names='???' \
tensorflowjs_converter \
    --input_format=tf_saved_model \
    --saved_model_tags=serve \
    model_tmp/model.ckpt-500 \
    model_web

Wrong! When I run the script above I get an error:

IOError: SavedModel file does not exist at: model_tmp/model.ckpt-500

I've tried model_tmp, model_tmp/checkpoint but neither of them work either.

Also, I'm not sure what to provide at output_node_names in the converter call.

$\endgroup$
1
$\begingroup$

You can build from source and use the summarize_graph tool which is distributed as a part of Tensorflow graph_transforms tools. Detailed docs are available here. Quick install:

First, make sure you have bazel build system installed (for MacOS):

brew install bazel

Next get Tensorflow sources, build and run summarize_graph:

git clone git@github.com:tensorflow/tensorflow.git
cd tensorflow
bazel build tensorflow/tools/graph_transforms:summarize_graph
bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --in_graph=path/to/model_graphdef.pb

Note that summarize_graph requires GraphDef format as input.

If during the build attempt bazel can't find Xcode, configure it:

bazel clean --expunge 
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
bazel clean --expunge 
$\endgroup$
0
$\begingroup$

tools/graph_transforms/summarize_graph OR /tools/benchmark:benchmark_model will show the input and outpt node names

$\endgroup$
1
  • $\begingroup$ Can you be more explicit in your answer? This is pretty terse. $\endgroup$
    – Stephen Rauch
    Sep 25 '18 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.