Skip to content
Snippets Groups Projects
Commit 77f78c04 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

For some reason tensorflow 1.8 was casting to uint8 the integer division.

parent 1292f743
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -27,7 +27,6 @@ def test_embedding_accuracy():
data = numpy.vstack((class_a, class_b))
labels = numpy.concatenate((labels_a, labels_b))
assert compute_embedding_accuracy(data, labels) == 1.
# Adding noise
......@@ -51,7 +50,9 @@ def test_embedding_accuracy_tensors():
class_b = numpy.random.normal(
loc=10, scale=0.1, size=(samples_per_class, 2))
labels_b = numpy.ones(samples_per_class)
class_b = numpy.vstack((class_b, numpy.array([0,0.])))# Adding outlier
labels_b = numpy.ones(samples_per_class + 1)
data = numpy.vstack((class_a, class_b))
labels = numpy.concatenate((labels_a, labels_b))
......@@ -61,4 +62,4 @@ def test_embedding_accuracy_tensors():
sess = tf.Session()
accuracy = sess.run(compute_embedding_accuracy_tensors(data, labels))
assert accuracy == 1.
assert abs(accuracy-7/11.) < 10e-3
......@@ -226,7 +226,7 @@ def compute_embedding_accuracy_tensors(embedding, labels, num=None):
tf.unstack(predictions, num=num), tf.unstack(labels, num=num))
]
return tf.reduce_sum(tf.cast(matching, tf.uint8)) / len(predictions)
return tf.reduce_sum(tf.cast(matching, tf.float32)) / len(predictions)
def compute_embedding_accuracy(embedding, labels):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment