jeudi 17 mai 2018

tf.reduce_max inconsistent on comparison

Given a list/tensor of items, I want to check whether the max item of the whole list is the same as the max item in specific part of list:

import tensorflow as tf
a = tf.get_variable('a', (10,100))
b = tf.unstack(a,axis=1)
c = tf.reduce_max(b[0])
d = tf.reduce_max(b[0])
if c == d:
  c = tf.ones((1,100))

sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run([c,d])

In the above example, c and d should be the same, however, when you run the model, it doesn't satisfy the condition to re-make variable c as a one vector. This is just an example to show that these types of comparison seem to be wrong. Any idea what would be the correct way to do it?

Aucun commentaire:

Enregistrer un commentaire