I am trying to train a deep learning algorithm in Keras with a Tensorflow backend. I am trying to do the following:
x = tf.reshape(theta, [-1])[K.argmax(image)]
Where image
is the input and eta
is a coordinate. I am trying to flatten theta, but I get the error
Only integers, slices (`:`), ellipsis (`...`), tf.newaxis (`None`) and scalar tf.int32/tf.int64 tensors are valid indices, got <tf.Tensor 'loss_42/dense_264_loss/ArgMax:0' shape=(25,) dtype=int64>
I guess you want to get the theta values according to the K.argmax(image)
. You cannot directly use fancy indexing style in the tensorflow. tf.gather
can achieve this instead.
res = tf.gather(tf.reshape(theta, [-1]), K.argmax(image))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With