nn.Conv2d, what kind of filters did it use when I specify different out_channels?

I noticed, I can specify how many filters the conv net should use, but what kind of filters are being used? (edge detection, sharpen etct ?) What is the difference when I specify this argument as 10 or 20?

As how I understood looks like there is a “filter pool”, and different number of filters will be randomly picked from the pool as specified by the out_channels?

Each filter will be randomly initialized (using this metho and trained. The filters will not be initialized as classical image processing filters, but the training procedure might of course yield filters which are similar to e.g. edge detectors etc.

Each filter will process the input activation and create an output activation map (in the default setup). The more filters a conv layer has, the more output channels (each processed by a single filter) it will yield. The higher the number of filters, the more “capacity” this layer has (similar to the number of neurons of a linear layer).

No, all filters, which were specified during the initialization of the conv layer, will be used.

Have a look at CS231n - Convolutions for a general overview how this layer works.

1 Like

“ Each filter will be randomly initialized (using [this metho and trained.”

So it means if I run the program twice with the same out_channels, nn.Conv2D might actually use different filters, just the number of filters will be the same.

Yes, if you don’t seed the code, this would be the case.
To get the same pseudo random values, you could have a look at the Reproducibility docs.

1 Like