Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Unexpected problem in creating a tensor on saved model session.

未關閉
#397 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
java

研究方向

使用 issue 中的 SavedModelBundle、Graph、Ops 和 tf.constant 重現該失敗,然後檢查第 413 行附近的 core/op/Constant.java,並將 MetaGraphDef 中的圖節點與 Ops 使用的圖進行比較。當可以從已儲存模型的圖建立所提供的 labels 張量,且不會出現重複節點錯誤時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

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;
image

主要語言
Java
星號
928
分支
227
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

tensorflow/java 的其他 Issue

查看 tensorflow/java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。