Search code examples
neural-networktorch

Unable to figure out nInputPlane in SpatialConvolution in torch?


Documentaion for Spatial Convolution define it as

module = nn.SpatialConvolution(nInputPlane, nOutputPlane, kW, kH, [dW], [dH], [padW], [padH])

nInputPlane: The number of expected input planes in the image given into forward().

nOutputPlane: The number of output planes the convolution layer will produce.

I don't have any experience with torch but i guess i have used a similar function in keras

Convolution2D(64, 3, 3, border_mode='same', input_shape=(3, 256, 256))

which takes as input the shape of the image that is 256*256 in rgb.

I have read usage of Spatial Convolution in torch as below but unable to figure out what does the nInputPlane and nOutputPlane paramter correspond to?

local convLayer = nn.SpatialConvolutionMM(384, 384, 1, 1, 1, 1, 0, 0)

In the code above what does these 384,384 represent ?


Solution

  • In case I'm not speaking common language you can refer to this.

    nIputPlane is the number of layers coming in to the convolution, nOutputPlane is number of layers coming out of the convolution. If you have an rgb image nInputPlane = 3 (assuming your tensor is setup correctly). nOutputPlane can be any number of layers that you want to come out of the spatial convolution but of course make sure the next layer input is equal to nOutputPlane.

    If that isn't clear I'd recommend the 60-minute blitz.