tensorflow / tensorflow/java

Unexpected problem in creating a tensor on saved model session.

オープン
#397 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
928
フォーク
227
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

issue にある SavedModelBundle、Graph、Ops、tf.constant を使って失敗を再現し、その後 core/op/Constant.java の 413 行目付近を調べ、MetaGraphDef のグラフノードと Ops が使用するグラフを比較します。保存されたモデルのグラフから、重複ノードエラーなしで提供された labels テンソルを作成できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
machine-learning
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。