malioboro
malioboro

Reputation: 3281

Value Error: Dimension Mismatch .., in Theano

I just followed convolutional neural network tutorial and try to re-write the code from: http://deeplearning.net/tutorial/code/convolutional_mlp.py

and I try to change the code from line 108, from:

self.output = T.tanh(pooled_out + self.b.dimshuffle('x', 0, 'x', 'x'))

to

self.output = T.tanh(conv_out + self.b.dimshuffle('x', 0, 'x', 'x'))

and then I got this error:

ValueError: dimension mismatch in args to gemm (500,20000)x(800,500)->(500,500)
Apply node that caused the error: GpuDot22(GpuElemwise{tanh,no_inplace}.0, W)
Toposort index: 40
Inputs types: [CudaNdarrayType(float32, matrix), CudaNdarrayType(float32, matrix)]
Inputs shapes: [(500, 20000), (800, 500)]
Inputs strides: [(20000, 1), (500, 1)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[GpuElemwise{Composite{tanh((i0 + i1))}}[(0, 0)](GpuDot22.0, GpuDimShuffle{x,0}.0)]]

I don't know why is this happen, because I think pooled_out and conv_out have the same shape in the second dimension

can someone help me to explain why is this happen?

Upvotes: 1

Views: 1592

Answers (1)

Daniel Renshaw
Daniel Renshaw

Reputation: 34177

The problem is not inside the LeNetConvPoolLayer it's in the following layer which is expecting the output from the LeNetConvPoolLayer to be one size but is getting something else.

To skip the pooling, you'll need to adjust every layer that follows a LeNetConvPoolLayer to expect its input to be the appropriately larger size.

Upvotes: 2

Related Questions