thanks, it works.

On Tuesday, April 22, 2014 at 5:30:06 AM UTC+3, Olivier Delalleau wrote:
>
> For instance:
> B = B.reshape((sh[0], sh[1]*sh[2]))
>
> -=- Olivier
>
> 2014-04-21 20:38 GMT-04:00 David Krueger <[email protected] 
> <javascript:>>:
>
>> I'm not sure what you mean, can you give me the syntax?
>>
>>
>>
>>
>> On Fri, Apr 18, 2014 at 6:14 PM, Olivier Delalleau <[email protected] 
>> <javascript:>> wrote:
>>
>>> Reshape takes symbolic values, you just need to provide the shape as a 
>>> single argument (add the missing parentheses).
>>>
>>> -=- Olivier
>>>
>>> Le 2014-04-18 à 16:07, David Krueger <[email protected] 
>>> <javascript:>> a écrit :
>>>
>>> I have a theano 3-tensor of arbitrary shape (call it B).  I want the 
>>> softmax of its 0th dimension.  
>>>
>>> So in numpy I might do:
>>>
>>> sh = B.shape
>>> B = B.reshape(sh[0], sh[1]*sh[2])
>>> B = softmax(B)
>>> B = B.reshape(sh[0],sh[1],sh[2])
>>>
>>> But this doesn't work in Theano, because (as I understand it) sh is 
>>> still a tensor variable, and so the reshape can't be compiled, because it 
>>> expects integers. 
>>>
>>> So my question is if it is possible to get something like the above in 
>>> Theano.
>>>
>>> This is the traceback for that code:
>>>
>>>
>>> ---------------------------------------------------------------------------
>>> ValueError                                Traceback (most recent call 
>>> last)
>>> /opt/lisa/os/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in 
>>> execfile(fname, *where)
>>>     176             else:
>>>     177                 filename = fname
>>> --> 178             __builtin__.execfile(filename, *where)
>>>
>>> /u/kruegerd/MDN_cost.py in <module>()
>>>     102 
>>>     103 cost = MDNCost()
>>> --> 104 exp = cost.expr(model, data)
>>>     105 
>>>     106 
>>>
>>> /u/kruegerd/MDN_cost.py in expr(self, model, data, **kwargs)
>>>      47         B = Y_hat.flatten(3).dimshuffle(1,0,2) # dimensions?
>>>      48         sh = B.shape
>>> ---> 49         B = B.reshape(sh[0], sh[1]*sh[2])
>>>      50         B = softmax(B)
>>>      51         Y_hat2 = B.reshape(sh[0],sh[1],sh[2])
>>>
>>> /u/kruegerd/repo/Theano/theano/tensor/var.pyc in reshape(self, shape, 
>>> ndim)
>>>     294             if not isinstance(ndim, int):
>>>     295                 raise ValueError("Expected ndim to be an 
>>> integer, is " +
>>> --> 296                                  str(type(ndim)))
>>>     297 
>>>     298         return theano.tensor.basic.reshape(self, shape, 
>>> ndim=ndim)
>>>
>>> ValueError: Expected ndim to be an integer, is <class 
>>> 'theano.tensor.var.TensorVariable'>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> -- 
>>>
>>> --- 
>>> 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 a topic in the 
>>> Google Groups "theano-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/theano-users/NhtV8j-63hA/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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] <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.

Reply via email to