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.

Import frozen graph of a LSTM has an error

See original GitHub issue

Using Tensorflow v1.11.0.

Please see here to reproduce the error: https://github.com/esdu/misc/blob/master/bug_report_lstm_freeze.ipynb

In the above notebook, I train a simple LSTM, try to freeze the graph, and load the frozen graph. Upon loading the frozen graph, I see an error:

InvalidArgumentError: Input 0 of node import/lstm/while/ReadVariableOp/Enter was passed float from import/lstm/kernel:0 incompatible with expected resource.

The lstm/kernel node was frozen into a Const, and lstm/while/ReadVariableOp/Enter cannot read it in. The same thing is observed for other variables related to the LSTM: lstm/bias and lstm/recurrent_kernel.

Any hints on how to freeze an LSTM trained in Keras?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
fafocommented, Oct 24, 2018

Same behaviour here. convert_variables_to_constants changes ReadVariableOps to Identity nodes after transforming computed variables to constants. However some variables are attached to Enter nodes which are incompatible with the generated constants (eg. they expect a resource and they receive a flot). Any idea how can we fix Enter nodes?

1reaction
chris0914commented, Dec 4, 2019

Same error occurs, when using Autograph with LSTM-layer. Running the current master branch on commit 7c5157667006181f16efa3b70468ec1bd62cb070. Any news on how to fix this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tensorflow - Unable to import frozen graph with batchnorm ...
I am trying to freeze in a pbtxt file a checkpoint containing batchnorm layers (tf 1.1.0). For this, following these posts and issues...
Read more >
Freezing a Keras model - Towards Data Science
Now that the model has been trained and the graph and checkpoint files made we can use TensorFlow's freeze_graph.py to merge these together....
Read more >
A Gentle Introduction to torch.autograd - PyTorch
We use the model's prediction and the corresponding label to calculate the error ( loss ). The next step is to backpropagate this...
Read more >
tf.Graph | TensorFlow v2.11.0
Returns the names of the collections known to this graph. finalized, True if this graph has been finalized. graph_def_versions, The GraphDef version information ......
Read more >
NVIDIA Deep Learning TensorRT Documentation
It selects subgraphs of TensorFlow graphs to be accelerated by TensorRT, while leaving the ... TensorRT's API has language bindings for both C++...
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