Search code examples
caffedeconvolution

Unexpected shape for deconv layer


I work on a deconv layer which upscales 64 channels : 64x48x48 => 64x96x96.

layer {
    bottom: "layer41_conv"
    top: "layertest_upsample"
    name: "layertest_upsample"
    type: "Deconvolution"
    convolution_param {
        num_output: 64
        group: 64
        kernel_size: 2
        pad: 0
        stride: 2
    }
}

When I print the shape of the parameters : (64,1,2,2). I was expected something like : (64,64,2,2) because of 64 channels in input and 64 channels in output. Can anyone explain me what's going on ?


Solution

  • You defined group: 64

    What group does is (according to manual):

    group (g) [default 1]: If g > 1, we restrict the connectivity of each filter to a subset of the input. Specifically, the input and output channels are separated into g groups, and the k-th output group channels will be only connected to the k-th input group channels.

    In your case you grouped all 64 channels into 64 groups - this that the k-th input channel is mapped (in isolation) by a 2x2 kernel to the k-th output channel. Over all you have 64 such 2x2 mappings and this is why your weight blob is 64x1x2x2 and not 64x64x2x2.
    If you remove the group: 64 you'll have the full weight matrix you expect.