Fix python theano.tensor.argmax() return argmax by examples

Consider python source code below:

import theano
import theano.tensor as T
import numpy

share_x = theano.shared(value = numpy.array([[1,2,3],[2,2,4]]), name = "x")

y = T.argmax(share_x)

print y

You can get output:argmax, not the index of the max number, why?

To theano function theano.tensor.argmax(), the input variable must be a Theano TensorVariable type, this function describes a computational graph, so you can not get index.

To use this function correctly, you can use theano.function() and read:

Learn python theano.tensor.argmax() by examples

Leave a Reply

Your email address will not be published. Required fields are marked *