Hi,

It is not possible to initialize a shared variable without a shape,
since it needs a value.

However, the shape of a shared variable is not fixed (only the number of
dimensions and dtype are).

So you could create a shared variable with shape (1, 1, ...) for
instance, and then either call set_value() or a function with
updates=... to properly initialize it when you actually know its shape.

On Wed, Nov 09, 2016, Peter O'Connor wrote:
> Hi all, I'm implementing a "temporal difference", which is just this:
> 
> class TemporalDifference(object):
> 
>     def __init__(self, shape):
>         self.old = theano.shared(np.zeros(shape))
> 
>     def __call__(self, data):
>         diff = data - self.old
>         add_update(self.old, data)
>         return diff
> 
> 
> It would be really nice not to have to pass in the shape in advance, as it 
> can be a bit difficult to figure out sometimes.  Is there some way to do 
> this without having to know the shape in advance?
> 
> Thanks.
> 
> -- 
> 
> --- 
> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to