Discussion:
[theano-users] Differences between theano.shared and numpy.ndarray.
佐藤優
2017-08-25 04:58:20 UTC
Permalink
I saw follown defferences:
import theano
import theano.tensor as T
import numpy as np

o = np.ones((1,2,3))
o2 = np.ones((2,1))
o2_shared = theano.shared(ones((2, 1)))

print((o2 + o).shape)
print((o2_shared + o).shape)

result is

(1, 2, 3)
[1 2 1]


Maybe, broadcasting result is difference.

But changing the order of calculation:
import theano
import theano.tensor as T
import numpy as np


o = np.ones((1,2,3))
o2 = np.ones((2,1))
o2_shared = theano.shared(ones((2, 1)))

print((o + o2).shape)
print((o + o2_shared).shape.eval())



result is same as follows:

(1, 2, 3)
[1 2 3]


Is this theano.shared bug?
--
---
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Frédéric Bastien
2017-08-28 13:05:40 UTC
Permalink
It is not a bug. Currently, by default the shape of a shared variable can
changes during the execution. So we can't use the shape to determine the
broadcasting pattern.

You can pass the parameter broadcastable=() where you put the broadcast
pattern. By default it is never broadcastable.

Fred
Post by 佐藤優
import theano
import theano.tensor as T
import numpy as np
o = np.ones((1,2,3))
o2 = np.ones((2,1))
o2_shared = theano.shared(ones((2, 1)))
print((o2 + o).shape)
print((o2_shared + o).shape)
result is
(1, 2, 3)
[1 2 1]
Maybe, broadcasting result is difference.
import theano
import theano.tensor as T
import numpy as np
o = np.ones((1,2,3))
o2 = np.ones((2,1))
o2_shared = theano.shared(ones((2, 1)))
print((o + o2).shape)
print((o + o2_shared).shape.eval())
(1, 2, 3)
[1 2 3]
Is this theano.shared bug?
--
---
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
For more options, visit https://groups.google.com/d/optout.
--
---
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...