Unexpected behavior from `tf.math.greaterEqual`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 928
- Fork
- 227
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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)
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con lo snippet Java e la TestSession in modalità GRAPH, quindi confronta il tensore generato e il risultato di tf.math.greaterEqual con l’esempio Python. Riproduci la discrepanza segnalata sull’elemento finale e identifica se è prodotta dal binding Java o dalla configurazione del test; il lavoro è completato quando il comportamento è spiegato e un test di regressione o una modifica correttiva è stata verificata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java, tensorflow
- Ambito
- machine-learning
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100