Also, never ignore the updates returned by theano.scan!
In other words, always do:

result, updates = theano.scan(...)
f = theano.function(..., updates=updates)

and never:

result, _ = theano.scan(...)

On Thu, Sep 29, 2016, 杨培 wrote:
> When I use theano loop with RandomStream to generate random number,
>  theano compile fail with “MissingInput”。
> 
> I Google this problem, and I found :
> 
>    - a  issue(https://github.com/Theano/Theano/issues/3437)。This issue said 
>    we cannot use RandomStream with symbolic shape in scan。
> 
> But I also found :
> 
>    - a documentation int Theano 
>    
> (http://deeplearning.net/software/theano/library/scan.html#using-shared-variables-gibbs-sampling),the
>  
>    code in the documentation use RandomStream with symbolic shape in scan。
>    
> So,how to use theano scan with RandomStream。Thanks for your help
> 
> here is my code。this code compile failed
> 
> 
>    - import theano;
>    - from theano import tensor as T;
>    - import numpy as np;
>    - 
>    - from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams;
>    - 
>    - x=T.ivector();
>    - 
>    - def step(i):
>    -     sample=RandomStreams().binomial(size=(i,));
>    -     return sample;
>    - 
>    - result,_=theano.scan(fn=step,outputs_info=None,
>    -                      sequences=[x]);
>    - 
>    - f=theano.function([x],result);
>    - 
>    - x_val=np.array([1,2,3],dtype='int32');
>    - print f(x_val);
>    
> 
> this code work fine
> 
>    - import theano;
>    - from theano import tensor as T;
>    - import numpy as np;
>    - 
>    - from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams;
>    - 
>    - x=T.ivector();
>    - len=x.shape[0];
>    - 
>    - def step(i):
>    -     len_=len;
>    -     sample=RandomStreams().binomial(size=(len_,));
>    -     return sample;
>    - 
>    - result,_=theano.scan(fn=step,outputs_info=None,
>    -                      sequences=[x]);
>    - 
>    - f=theano.function([x],result);
>    - 
>    
> 
>    - x_val=np.array([1,2,3],dtype='int32');
>    - print f(x_val);
>    
> 
> 
> 
> 
> -- 
> 
> --- 
> 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.

Reply via email to