Pete Janda
Pete Janda

Reputation: 73

How does Caffe Convolution Layer's Num of Outputs Work with Kernel and Stride Sizes?

Perhaps a noob question, but after reading the caffe.proto file on Github, I cannot reconcile how two (really three) specs for the convolution layer co-exist:

  1. Number of outputs;
  2. Kernel size and stride.

Don't the kernel size and stride necessarily dictate a convolution layer's number of outputs? I see in the .proto file that the number of outputs is an optional spec, which leads me to believe that the number of outputs can be user-defined rather than a derived function of kernel size and stride. Is this true? If yes, for what purpose?

Upvotes: 1

Views: 529

Answers (2)

Rachit Tayal
Rachit Tayal

Reputation: 1292

Convolution layers takes in volumes as input and output. The output volume depends on:-

1. Kernel size
2. Kernel stride
3. padding 
4. No of kernels (filters)

For example:- if input volume is 32x32x3 and convolution layer has 10 (no of kernels) 5x5 (kernel size) filters with stride 1 and pad 2 then output size spatially would be:-

input_size+pad*2-kernel_size/stride+1

(32+2*2-5)/1+1 = 32 therefore spatially the size would be 32x32 And the depth of output is always equal to No of kernels. i.e. 10 hence output volume will be 32x32x10

Upvotes: 1

nomem
nomem

Reputation: 1588

No. num_output refers to the number of channels of the output whereas kernel_size, pad,stride are used to calculate size of each channel.

Upvotes: 1

Related Questions