Hi Fred,
Thanks. I implemented in two ways, one as you told me, and the other using
a share variable. However, I not sure if the second is correct. Could you
confirm me if the implementations are correct?
Implementation 1:
init_state = tensor.alloc(0., nsteps + 1, n_samples, dim)
init_state = tensor.set_subtensor(init_state[0], init_state_0)
state_below_=...
time_step = tensor.arange(nsteps).astype('int64') + 1
def _step(x_,t_, h_)
....
h_ = tensor.set_subtensor(h_[t_], h)
return h_
rval, updates = theano.scan(_step,
sequences=[state_below_, time_step],
outputs_info=[init_state],
n_steps=nsteps)
Implementation 2:
mem_h = tensor.alloc(0., nsteps + 1, n_samples, dim)
mem_h = tensor.set_subtensor(mem_h[0], init_state_0)
state_below_=...
time_step = tensor.arange(nsteps).astype('int64') + 1
def _step(x_,t_, h_, mem_h)
....
mem_h = tensor.set_subtensor(mem_h[t_], h)
return h
rval, updates = theano.scan(_step,
sequences=[state_below_, time_step],
outputs_info=[init_state_0],
non_sequences=[mem_h]
n_steps=nsteps)
Thanks again
On Friday, March 3, 2017 at 2:46:27 PM UTC+1, nouiz wrote:
>
> Sadly it isn't trivial. The normal scan behavior is to return a fixed
> number of previous taps.
>
> But you can do it. Make one of your input as big as the output and add an
> input that is the iterations number. Then you will return that input where
> you set row i to the value of that iteration with set_subtensor.
>
> I think this will use more memory them needed if you take the gradient.
>
> Fred
>
> Le mer. 1 mars 2017 10:12, Lesly M. <[email protected] <javascript:>> a
> écrit :
>
>> Hello,
>>
>> I need to get all previous tabs values at each iteration with scan. The
>> documentation shows how to get individual tabs like t-n or t+n, but I would
>> like to have all from time 0 to t-1. Is it possible?
>>
>> Thanks,
>>
>> Lesly
>>
>> --
>>
>> ---
>> 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] <javascript:>.
>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.