question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tensorflowjs_converter and scalars instead of tensors

See original GitHub issue

TensorFlow.js version

{“tfjs-core”: “0.12.11”, “tfjs-layers”: “0.7.4”, “tfjs-converter”: “0.5.7”, tfjs: “0.12.5” }

Describe the problem

There’s something wrong in the conversion process from frozenModels. In fact, when I actually created the model (in python - tensorflow) I wrote:

self.scalarInput = tf.placeholder(shape=[None,21168],dtype=tf.float32, name=“main_scalarinput”)

I correctly do predictions in a C++ Tensorflow-based application that uses a frozen version of this model. I’d like to do the same in a tfjs-based webapp. However, after running tensorflowjs_converter and writing the code to load the converted model, I am not able to feed data in the model, since it accepts only scalars. Inspecting the model inputs I can see:

0: Object { name: "main_scalarinput", **shape: []**, dtype: "float32" }
1: Object { name: "main_batch_size", shape: [], dtype: "int32" }
2: Object { name: "main_train_length", shape: [], dtype: "int32" }

which is in contrast with the actual definition of the model.

.pb model here: https://drive.google.com/file/d/1tU-6tYhXTGhFOjy6Eycqt2rwnOoOYmw6/view?usp=sharing

Any workaround?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
icysapphirecommented, Aug 21, 2018

Great, @pyu10055, thanks a lot! I’m waiting for npmjs publish in order to try that! [ETA?] In the meanwhile, I’d like to ask you for another problem with my unlucky model… in my model there’s a LSTM cell: in python (but also in the C++ tensorflow-based app) I am able to feed in the input tensor and also a particular rnn state, do inference, get back output and rnn state (to be used in the next inference execution with another input)… however tfjs refuses input at node named “main_state_in” because it has already decided that this is not an input node. How can I specify in the tfjs conversion process that this particular node is input?

Here it is the graphdef: standard_DRQN_graphdef.pbtxt.zip

0reactions
yokingscommented, Oct 23, 2018

is your output of tf version code same with your tfjs version code?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tensors and operations | TensorFlow.js
js is a framework to define and run computations using tensors in JavaScript. A tensor is a generalization of vectors and matrices to...
Read more >
tensorflow.js - Scalar multiplication of tensors - Stack Overflow
I would like to scale tensors in TensorFlow.js. By trying for instance a * 0.1 I get an error message (at least from...
Read more >
Introduction to the TensorFlow.js core API / Nikhil Thorat
How do I convert from deeplearn.js to TensorFlow.js? ... Inside this function, your responsibility is to produce the scalar Tensor to minimize.
Read more >
4. Image Tensors - Learning TensorFlow.js [Book] - O'Reilly
Build some images by hand. Use fill methods to create large tensors. Convert existing images to tensors and back. Manipulate image tensors in...
Read more >
Tensorflow.js Crash-Course - Gilbert Tanner
In Tensorflow.js, we can create a scalar-tensor by typing: ... Instead, you will convert pre-trained models from Tensorflow or Keras to Tensorflow.js and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found