When writing cnn with pytorch, use torch.nn and write as follows
conv1 = torch.nn.Conv2d(in_channels , out_channels , kernel_size , stride , padding)
Since in_channel and out_channels are the number of kernel channels, they have nothing to do with the image size.
It is the size of the pooling layer and the size of the stride that determine the input and output image size (feature map). So when stacking two or more layers of cnn, I think it will work if you take care to make the out_channel of the previous layer equal to the in_channel of the next layer.
Recommended Posts