On Thu, Oct 06, 2016, daniel hernandez wrote: > I am starting with theano and for the life of me, I can't figure out how to > define a simple TensorVariable whose eval method returns a constant. theano > itself defines such variables, for instance > > > E = T.eye(2) > > type(E) > > theano.tensor.var.TensorVariable > > > > E.eval() > > array([[ 1., 0.], > [ 0., 1.]]) > > > > So, what is theano doing under the hood here? how do I assign a constant > value to a dscalar x?
Under the hood, it is doing: >>> f = theano.function(inputs=[], outputs=E) >>> f() In this case it works, because the value of E only depends en constants (here, 2). > > x = T.dscalar('x') > > type(x) > > theano.tensor.var.TensorVariable In that case, you can use the explicit version: >>> f = theano.function(inputs=[x], outputs=x) >>> f(3) or the "eval shortcut" >>> x.eval({x: 3}) > Also, if someone knows of a reference that answers these basic questions that > are not answered in the docs, I would be grateful. You can start with http://deeplearning.net/software/theano/tutorial/index.html > > > daniel > > -- > > --- > You received this message because you are subscribed to the Google Groups > "theano-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to theano-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Pascal -- --- You received this message because you are subscribed to the Google Groups "theano-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.