user19346
user19346

Reputation: 303

5D tensor in Theano

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?

Upvotes: 1

Views: 518

Answers (2)

Mohit Agarwal
Mohit Agarwal

Reputation: 11

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.

Upvotes: 1

Amir
Amir

Reputation: 11096

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.

Upvotes: 1

Related Questions