5D tensor in Theano

515 views Asked by At

I was wondering how to make a 5D tensor in Theano.

Specifically, I tried dtensor = T.TensorType('float32', (False,)*5). However, the only issue is that dtensor.shapereturns: AttributeError: 'TensorType' object has no attribute 'shape'

Whereas if I used a standard tensor type likedtensor = T.tensor3('float32'), I don't get this issue when I call dtensor.shape. Is there a way to have this not be an issue with a 5D tensor in Theano?

2

There are 2 answers

4
Amir On BEST ANSWER

Theano variables do not have explicit shape information since they are symbolic variables, not numerical. Even dtensor3 = T.tensor3(T.config.floatX) does not have an explicit shape. When you type dtensor3.shape you'll get an object Shape.0 but when you do dtensor3.shape.eval() to get its value you'll get an error.

For both cases however, dtensor.ndim works and prints out 5 and 3 respectively.

0
Mohit Agarwal On
dtensor = T.TensorType('float32',(False,)*5) 

only calls the function TensorType. In order to use the attribute dtensor.shape you need to make it an object. You can do it by:

dtensor = T.TensorType('float32',(False,)*5) ()

You can specify the name inside the parenthesis at the end if you wish.