Search code examples
conv-neural-networkcaffelayershapespycaffe

Irregular size in shapes in caffe model


When I tried to make my own model in caffe like this:

n.data = L.Input(input_param={'shape':{'dim':[1,1,64,64]}})
n.conv1 = L.Convolution(n.data, kernel_size=5,
                    num_output=16, pad=1, weight_filler=dict(type='xavier'))
n.elu1 = L.ELU(n.conv1, in_place=True)
n.scale1 = L.Scale(n.elu1, bias_term=False, in_place=True)

I got a output shape of 62x62x16 but the right thing would be to get one of 64x64x16, is there a mistake in my code?


Solution

  • Output_size is ((Input_size+2(padding)-kernel_size)/Stride)+1

    Input_size is 64 , kernel_size is 5, padding is 1

    So ((64+2-5)/1)+1 = 62

    You need to change the padding or kernel_size.