Unexpected problem in creating a tensor on saved model session.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 928
- Forks
- 227
- PR merge metrics
- No merged PRs in 30d
Description
System information
- OS Platform and Distribution: Linux Ubuntu 20.04 x64
- TensorFlow installed from: pip for Python 3.9; Maven for Java
- TensorFlow version : 2.7.0 on Python; 0.3.3 on Java
- Java version : openjdk 11.0.11 2021-04-20
- Python version : 3.9
- CUDA/cuDNN version: cuda_11.5.r11.5/compiler.30411180_0
- GPU model and memory: Nvidia Geforce 960m
Describe the current behavior
The model (a Keras Sequential) is saved using python's "tf.saved_model.save". This model is then loaded in Java using SavedModelBundle from which the related graph is extracted. Then and Ops is created using this graph. When trying to create a tensor using .constant method, an exception is thrown on line 413, /core/op/Constant.java saying
Duplicate node name in graph: 'Const'
I checked my graph nodes using getNodeList of MetaGraph and there is only one node named "Const".
Describe the expected behavior
Successful creation of Tensor as there is no duplicate in the graph nodes.
Code to reproduce the issue
SavedModelBundle model = SavedModelBundle.load("/path/to/model");
Graph graph = model.graph();
MetaGraphDef mataGF = model.metaGraphDef();
var nodes = mataGF.getGraphDef().getNodeList().toArray();
Ops tf = Ops.create(graph);
double[] labels = {0.52,0.65,0.23,0.54,0.65,0.16,0.97};
var input = tf.constant(labels);
Other info / logs
Here is a list of all the 37 nodes. Only node 31 is called Const;

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with SavedModelBundle, Graph, Ops, and tf.constant from the issue, then inspect core/op/Constant.java around line 413 and compare the graph nodes from MetaGraphDef with the graph used by Ops. Done means the supplied labels tensor can be created from the saved model graph without a duplicate-node error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100