[theano-users] Re: tensor grad with respect to shared variable

2017-05-19 Thread phamminhquang pham
You're right. Many thanks!

On Thursday, May 18, 2017 at 11:59:17 AM UTC+2, phamminhquang pham wrote:
>
>  I have tried following code and it's result confuse me.
>
> import theano
> import theano.tensor as T
> 
> import theano
> import theano.tensor as T
>
> t = theano.shared(5,'t')
> y = t ** 2
> grad = T.grad(y, wrt = t)
> f = theano.function([],y)
> g = theano.function([],grad)
> print(f())
> print(g())
>
> And i got 25 and 0.0 in return. However, the gradient must be 10. I think 
> there's some detail in tensor grad that i dont know. Could you please 
> explain to me what happened?
>

-- 

--- 
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.


[theano-users] Re: tensor grad with respect to shared variable

2017-05-18 Thread Jesse Livezey
t will have dtype "int64" because 5 is an integer. If you do
t = theano.shared(5.,'t') # added period after 5
it should work

On Thursday, May 18, 2017 at 2:59:17 AM UTC-7, phamminhquang pham wrote:
>
>  I have tried following code and it's result confuse me.
>
> import theano
> import theano.tensor as T
> 
> import theano
> import theano.tensor as T
>
> t = theano.shared(5,'t')
> y = t ** 2
> grad = T.grad(y, wrt = t)
> f = theano.function([],y)
> g = theano.function([],grad)
> print(f())
> print(g())
>
> And i got 25 and 0.0 in return. However, the gradient must be 10. I think 
> there's some detail in tensor grad that i dont know. Could you please 
> explain to me what happened?
>

-- 

--- 
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.