converter question

36 views
Skip to first unread message

Rohan Mahajan

unread,
Mar 25, 2021, 1:17:19 AM3/25/21
to TensorFlow.js Discussion
Hi,
I am not sure how the inputs are translated with the tfjs converter with named inputs.
https://colab.research.google.com/drive/1F1xO8950vJrw2JfVUDiid5pXAdOoo0lI?usp=sharing. I run this code multiple times and the order that the inputs appear in the conversion file change everytime(code is the same just reset runtime.) Additionally, the names change everytime, ie sometimes times input_0 and 1, sometimes input_5, input_6(no input 1 through 4) and the order that these appear in the json everytime changes.   I was wondering if  anything can be done as it means everytime I receonvert my model  I have to change my tfjs code. I also have many inputs of same dimensions so is there is any way to figure out the mapping happens. 
I also have attached a screen recording explaining my issues: https://share.descript.com/view/5xYQx07Q7T4
Thanks,
Rohan

Na Li

unread,
Mar 25, 2021, 7:43:50 PM3/25/21
to Rohan Mahajan, TensorFlow.js Discussion
Hi Rohan,
Is the savedModel's input signature order same every time?

Na

--
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.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/dd7a794a-80bd-4ac0-9436-c8b8f3722a8cn%40tensorflow.org.

Na Li

unread,
Mar 25, 2021, 10:48:47 PM3/25/21
to Rohan Mahajan, TensorFlow.js Discussion
I just copied your colab and ran it. I printed out the input signature from the saved model and tried several times, the input signature's order changes everytime. Try this:
```
loaded = tf.saved_model.load("/content/final3")
infer = loaded.signatures["serving_default"]
print(infer.structured_input_signature)
```

On Thu, Mar 25, 2021 at 7:04 PM Rohan Mahajan <roh...@uplara.com> wrote:
Sorry I am not clear what you mean by input signature of the saved model. I am not sure   Can you clarify what you mean by this?
Is it related to this https://www.tensorflow.org/tfx/serving/signature_defs?  I can't understand the pb files created by saved models. 

I run this code everytime. The inputs have the same name. Everything is the same.  I just reset the runtime. 
https://colab.research.google.com/drive/1F1xO8950vJrw2JfVUDiid5pXAdOoo0lI?usp=sharing
The converter command I am using is !tensorflowjs_converter --input_format=tf_saved_model /content/final3 multipleoutputs4.
I observe different input_names and the actual objects are ordered differently irrespective of name.

Na Li

unread,
Mar 26, 2021, 5:13:25 PM3/26/21
to Rohan Mahajan, TensorFlow.js Discussion
Please reference this document for how to specify input signature: https://www.tensorflow.org/api_docs/python/tf/saved_model/save


On Fri, Mar 26, 2021 at 4:37 AM Rohan Mahajan <roh...@uplara.com> wrote:
Sure is there something I can do to stop this from happening? What would you suggest is the best workaround?
Thanks,
Rohan

Rohan Mahajan

unread,
Mar 26, 2021, 7:54:03 PM3/26/21
to Na Li, TensorFlow.js Discussion
Thanks, I'll check it out. 

Na Li

unread,
Mar 30, 2021, 6:52:52 PM3/30/21
to Rohan Mahajan, TensorFlow.js Discussion
Hi Rohan,
Once you have named input signature, you can pass NamedTensorMap to tfjs's execute or predict api, this way, the order doesn't matter.

Rohan Mahajan

unread,
Apr 2, 2021, 8:20:29 AM4/2/21
to TensorFlow.js Discussion, Na Li, TensorFlow.js Discussion, Rohan Mahajan
Yes totally makes sense. 
Reply all
Reply to author
Forward
0 new messages