Thank you. :)
On Thursday, 27 July 2017 00:42:00 UTC+5:30, Pascal Lamblin wrote:
>
> Since the step function only returns one single variable, the first value
> returned by scan() is also one single variable. So it should be:
> h, _ = theano.scan(step , sequences=[x])
>
> If instead you use
> [h], _ = theano.scan(step , sequences=[x])
> then it is trying to expand that variable into a list of one element,
> which it is not able to do since it does not know its length.
>
> On Wednesday, July 26, 2017 at 8:56:03 AM UTC-4, Sunjeet Jena wrote:
>>
>>
>> Any idea why this code is not working?
>>
>>
>> import theano
>> from theano import tensor
>> from theano import shared
>> from theano import function
>> import numpy as np
>>
>> x=tensor.ivector('x')
>>
>> def step(u_t):
>>
>>
>> h=u_t*1
>>
>> return h
>>
>> [h], _ = theano.scan(step , sequences=[x])
>>
>> f=function([x],[h])
>>
>> b=[1,2,3,4,5,6]
>> print(f(b))
>>
>> *Error is: *
>>
>> Traceback (most recent call last):
>> File "Test1.py", line 31, in
>> [h], _ = theano.scan(step , sequences=x)
>> File "/usr/local/lib/python2.7/dist-packages/theano/tensor/var.py",
>> line 596, in __iter__
>> for i in xrange(theano.tensor.basic.get_vector_length(self)):
>> File "/usr/local/lib/python2.7/dist-packages/theano/tensor/basic.py",
>> line 4685, in get_vector_length
>> raise ValueError("length not known: %s" % msg)
>> ValueError: length not known: for{cpu,scan_fn} [id A] ''
>> |Subtensor{int64} [id B] ''
>> | |Shape [id C] ''
>> | | |Subtensor{int64::} [id D] 'x[0:]'
>> | | |x [id E]
>> | | |Constant{0} [id F]
>> | |Constant{0} [id G]
>> |Subtensor{:int64:} [id H] ''
>> | |Subtensor{int64::} [id D] 'x[0:]'
>> | |ScalarFromTensor [id I] ''
>> | |Subtensor{int64} [id B] ''
>> |Subtensor{int64} [id B] ''
>>
>> Inner graphs of the scan ops:
>>
>> for{cpu,scan_fn} [id A] ''
>> >Elemwise{mul,no_inplace} [id J] ''
>> > |x[t] [id K] -> [id H]
>> > |TensorConstant{1} [id L]
>>
>>
>>
>>
>>
--
---
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.