Hi Fred, thanks for the info, will try that.

On Tuesday, 11 October 2016 20:51:49 UTC+8, nouiz wrote:
>
> Update to Theano dev version. There was update to it since the last 
> release that could help you.
>
> Fred
>
> Le 11 oct. 2016 01:31, "狄凯" <dika...@gmail.com <javascript:>> a écrit :
>
>> Hi guys, I'm trying to use theano bilinear_upsampling function to write a 
>> custom layer for Keras.
>> I just failed to make a simple function with it.
>> Below is my example showing this failure:
>>
>> import theano.tensor as T
>> from theano import function
>> from theano.tensor.nnet.abstract_conv import bilinear_upsampling
>> x = T.tensor4('x')
>> y = bilinear_upsampling(x, 2)
>>
>> I get the following error:
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File 
>> "/home/dikai/bin/anaconda2/lib/python2.7/site-packages/theano/tensor/nnet/abstract_conv.py",
>>  
>> line 569, in bilinear_upsampling
>>     row * ratio, col * ratio))
>>   File 
>> "/home/dikai/bin/anaconda2/lib/python2.7/site-packages/theano/tensor/var.py",
>>  
>> line 327, in reshape
>>     return theano.tensor.basic.reshape(self, shape, ndim=ndim)
>>   File 
>> "/home/dikai/bin/anaconda2/lib/python2.7/site-packages/theano/tensor/basic.py",
>>  
>> line 4526, in reshape
>>     newshape = as_tensor_variable(newshape)
>>   File 
>> "/home/dikai/bin/anaconda2/lib/python2.7/site-packages/theano/tensor/basic.py",
>>  
>> line 208, in as_tensor_variable
>>     raise AsTensorError("Cannot convert %s to TensorType" % str_x, 
>> type(x))
>> theano.tensor.var.AsTensorError: ('Cannot convert (None, None, 
>> Elemwise{mul,no_inplace}.0, Elemwise{mul,no_inplace}.0) to TensorType', 
>> <type 'tuple'>)
>>
>> I thought the problem was because I didn't specify batch_size and 
>> num_input_channels of the bilinear_upsampling function, so I tested the 
>> following code:
>>
>> import theano.tensor as T
>> from theano import function
>> from theano.tensor.nnet.abstract_conv import bilinear_upsampling
>> x = T.tensor4('x')
>> y = bilinear_upsampling(x, 2, batch_size=x.shape[0], 
>> num_input_channels=x.shape[1])
>>
>> I got a different error:
>>
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File 
>> "/home/dikai/bin/anaconda2/lib/python2.7/site-packages/theano/tensor/nnet/abstract_conv.py",
>>  
>> line 542, in bilinear_upsampling
>>     filter_flip=True)
>>   File 
>> "/home/dikai/bin/anaconda2/lib/python2.7/site-packages/theano/tensor/nnet/abstract_conv.py",
>>  
>> line 241, in conv2d_grad_wrt_inputs
>>     integer_types, type(None)))
>> AssertionError
>>
>> I also checked the source code that raised this error:
>>
>> # checking the type of input_shape 
>> for dim in [0, 1]: 
>> assert isinstance(input_shape[dim], (theano.tensor.TensorConstant, 
>>
>> integer_types, type(None)))
>>
>> I don't know if this is a bug or not. Or can anyone provide a working 
>> example that upsamples a 4D tensor using this function (assuming actual 
>> shape of x is known only at runtime)?
>>
>> -- 
>>
>> --- 
>> 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...@googlegroups.com <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 theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to