Unexpected behavior from `tf.math.greaterEqual`
オープン
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 928
- フォーク
- 227
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
Custom code - OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
macOS BigSur 11.1 - TensorFlow installed from (source or binary):
TensorFlow Java latest GitHub, based on karl/tensor-ttype
I have the following code snippet.
Operand<TFloat32> r = tf.random.randomUniform(tf.constant(Shape.of(3,2)), TFloat32.class,
RandomUniform.seed(1001L));
Operand<TFloat32> rate1 = tf.constant(0.5f);
Operand<TBool> mask = tf.math.greaterEqual(r, rate1);
The generated random sequence (shape 3,2) is:
0,0). 0.028465
0,1). 0.936395
1.0). 0.035310
1,1). 0.230565
2,0). 0.269415
2,1). 0.145439
Describe the current behavior
When I run this code, I get mask values of:
0,0). false
0,1). true
1,0). false
1,1). false
2,0). false
2,1). true
Describe the expected behavior
I expected mask values to be:
0,0). false
0,1). true
1,0). false
1,1). false
2,0). false
2,1). false
The last random number, 0.145439, is less than 0.5.
Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.
try (TestSession session = TestSession.createTestSession(TestSession.Mode.GRAPH)) {
Ops tf = session.getTF();
Operand<TFloat32> random = tf.random.randomUniform(tf.constant(Shape.of(3,2), TFloat32.class,
RandomUniform.seed(1001L));
Operand<TFloat32> rate = tf.constant(0.5f);
Operand<TBool> mask = tf.math.greaterEqual(r, rate);
System.out.println("******** MASK ***************");
System.out.println("random:");
session.print(random);
System.out.println("rate1:");
session.print(rate1);
System.out.println("mask:");
session.print(mask);
System.out.println("******** MASK ***************");
}
If I do this code in Python it works as expected:
import tensorflow as tf
a = [
[0.028465 , 0.936395],
[0.035310 , 0.230565],
[0.269415 , 0.145439]
]
print(a);
rate = 0.5
b = tf.math.greater_equal(a, rate);
print(b)
Output:
[[0.028465, 0.936395], [0.03531, 0.230565], [0.269415, 0.145439]]
tf.Tensor(
[[False True]
[False False]
[False False]], shape=(3, 2), dtype=bool)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Java スニペットと GRAPH モードの TestSession から始め、生成されたテンソルと tf.math.greaterEqual の結果を Python の例と比較します。報告された最後の要素の不一致を再現し、それが Java バインディングによるものかテスト設定によるものかを特定します。動作が説明され、回帰テストまたは修正変更が検証されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java, tensorflow
- 領域
- machine-learning
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100