Variables inside a graph are mutable if you fetch them
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
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS, Oracle Linux 7.
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): v0.3.1
Describe the current behavior
This test fails as initial = 3.0f and after = 9.0f.
public void mutableVariablesTest() {
try (Graph g = new Graph();
Session s = new Session(g);
TFloat32 inputTensor = TFloat32.vectorOf(1.0f,1.0f,1.0f)) {
Ops tf = Ops.create(g);
Placeholder<TFloat32> input =
tf.withName("input").placeholder(TFloat32.class, Placeholder.shape(Shape.of(3)));
Variable<TFloat32> a = tf.variable(tf.constant(new float[]{1.0f,1.0f,1.0f}));
ReduceSum<TFloat32> output = tf.withName("output").reduceSum(tf.math.mul(a,input),tf.constant(0));
Init init = tf.init();
s.run(init);
Tensor t = s.runner().feed(input,inputTensor).fetch(output).run().get(0);
float initial = ((TFloat32)t).getFloat();
t.close();
TFloat32 aTensor = (TFloat32) s.runner().fetch(a).run().get(0);
aTensor.setFloat(3.0f,0);
aTensor.setFloat(3.0f,1);
aTensor.setFloat(3.0f,2);
aTensor.close();
t = s.runner().feed(input,inputTensor).fetch(output).run().get(0);
float after = ((TFloat32)t).getFloat();
t.close();
assertEquals(initial,after);
}
}
It fails when running on CPU on macOS and Linux. I checked on Linux on a GPU and the test passes.
Describe the expected behavior
The test should pass consistently across all backends, as I would expect to get a copy of the weights back rather than something that lets me directly mutate the state of the graph in all cases rather than just on GPU. At the very least it should fail consistently on both CPU and GPU, but I think we should disallow direct mutation of variables outside of a graph.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với ví dụ mutableVariablesTest trong issue và tái hiện nó trên các backend CPU và GPU được mô tả ở đó. Truy vết cách các tensor Variable được lấy về được xử lý, sau đó xác minh rằng việc lấy về không đột ngột làm thay đổi trạng thái đồ thị và hành vi nhất quán giữa các backend.
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