help with tfjs converter for saved model - weights not saved and weights_manifest.json only has the output node

142 views
Skip to first unread message

Dan Oved

unread,
Feb 22, 2019, 8:50:01 PM2/22/19
to TensorFlow.js Discussion
I'm struggling to figure out how to properly save a tensorflow model that was saved as a saved_model method and convert it to tensorflow.js.  It would be great if there was an end to end tutorial that shows how to do this.

Anyways, the model I want to convert is from this jupyter notebook "RNN for Human Activity Recognition - 2D Pose Input":

The full code for building and training the graph can be found in that jupyter notebook.

I can successfully run the code:

save_path = "/content/gdrive/My Drive/saved_model/"

tf
.saved_model.simple_save(sess,
  save_path
,
  inputs
={"x":x},
  outputs
={"y": y})

From looking at the graph building code I'm not entirely sure what the output_node_names should be in the tensorflowjs_converter command, because when I put in y I get an error that the node does not exist. I printed out all the graph nodes and am guessing it's mul_1/y , as this is what's in the graph building code:

def LSTM_RNN(_X, _weights, _biases):
   
# model architecture based on "guillaume-chevalier" and "aymericdamien" under the MIT license.

    _X
= tf.transpose(_X, [1, 0, 2])  # permute n_steps and batch_size
   
# rest of graph building code left out for this post
   
# Linear activation
   
return tf.matmul(lstm_last_output, _weights['out']) + _biases['out']

When I run the command:

!tensorflowjs_converter \
    --input_format=tf_saved_model \
    --output_node_names="mul_1/y" \
    --saved_model_tags=serve \
    /content/gdrive/My\ Drive/saved_model/ \
    /content/gdrive/My\ Drive/web_model/

It succeeds with this message:

Using TensorFlow backend.
2019-02-23 01:46:53.475557: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Writing weight file /content/gdrive/My Drive/web_model/tensorflowjs_model.pb...

However, the tensorflowjs_model.pb file is only 50 bytes, and all that's contained within weights_manifest.json is:

[{"paths": ["group1-shard1of1"], "weights": [{"name": "mul_1/y", "shape": [], "dtype": "int32"}]}]

What am I doing wrong?

Edoh Kodjo

unread,
Feb 23, 2019, 1:32:49 AM2/23/19
to Dan Oved, TensorFlow.js Discussion
You can ask the question on stackoverflow.com

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/0e900c15-5175-49fe-ba4e-b2fb8cac0dec%40tensorflow.org.

Dan Oved

unread,
Feb 23, 2019, 1:46:33 AM2/23/19
to TensorFlow.js Discussion, ove...@gmail.com
Thank you - I didn't realize that's the venue for these support questions. I've posted it here:
Reply all
Reply to author
Forward
0 new messages