1

Im having issues on how to understand how Convolution Layers are added. Im trying to add Convolution Layers but i get this error :

ValueError: GpuCorrMM shape inconsistency:
  bottom shape: 128 32 30 30
  weight shape: 3 32 3 3
  top shape: 128 1 28 28 (expected 128 3 28 28)

Apply node that caused the error: GpuCorrMM_gradInputs{valid, (1, 1)}(GpuContiguous.0, GpuContiguous.0)
Inputs types: [CudaNdarrayType(float32, 4D), CudaNdarrayType(float32, 4D)]
Inputs shapes: [(3, 32, 3, 3), (128, 1, 28, 28)]
Inputs strides: [(288, 9, 3, 1), (784, 0, 28, 1)]
Inputs values: ['not shown', 'not shown']

Im trying to understand what is nb_filter, stack_size, nb_row, nb_col are on a convolutional layer.

My Objective is to copy the VGG Model.

model = Sequential()

model.add(Convolution2D(32, 1, 3, 3, border_mode='full'))
model.add(Activation('relu'))
model.add(Convolution2D(32, 32, 3, 3))
model.add(Activation('relu'))
model.add(MaxPooling2D(poolsize=(2, 2)))
model.add(Dropout(0.25))

model.add(Convolution2D(64, 32, 3, 3, border_mode='full'))
model.add(Activation('relu'))
model.add(Convolution2D(64, 64, 3, 3))
model.add(Activation('relu'))
model.add(MaxPooling2D(poolsize=(2, 2)))
model.add(Dropout(0.25))

model.add(Flatten())
model.add(Dense(64*8*8, 512))
model.add(Activation('relu'))
model.add(Dropout(0.5))

model.add(Dense(512, nb_classes))
model.add(Activation('softmax'))

# let's train the model using SGD + momentum (how original).
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy', optimizer=sgd)

-- Im currently using Theano and keras.

Please, any tip is appreciated.

MBT
  • 14,333
  • 16
  • 60
  • 88
  • Please provide the exact line you use to do the training. It is missing. – eickenberg Jul 04 '15 at 10:38
  • 2
    Your error does not seem to correspond to the architecture you are defining. It seriously helps to post *working code* (as in *works by copying and pasting*) in order for people willing to help not to waste their time. – eickenberg Jul 04 '15 at 10:41

1 Answers1

0

You need to correct the output shape for the convolutional layer. Output of a CNN layer depends on many factors such as input size, number of kernels, stride and padding. Generally for an input of size BxCxW1xH1, the output would be BxFxW2xH2 where B is the batch size, C is the input channels, F is the number of output features, W1xH1 is the input size and you can compute the value of W2 and H2 using W1, H1, stride and padding. It is illustrated very well in this tutorial from Stanford: http://cs231n.github.io/convolutional-networks/#comp

Hope it helps!

dipendra009
  • 301
  • 2
  • 7