tensorflow / tensorflow/java

Unexpected problem in creating a tensor on saved model session.

Đang mở
#397 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Java
Star
928
Fork
227
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện lỗi với SavedModelBundle, Graph, Ops và tf.constant từ issue, sau đó kiểm tra core/op/Constant.java quanh dòng 413 và so sánh các nút đồ thị từ MetaGraphDef với đồ thị được Ops sử dụng. Hoàn tất khi tensor labels được cung cấp có thể được tạo từ đồ thị mô hình đã lưu mà không gặp lỗi nút trùng lặp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
machine-learning
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.