When we slide the filter matrix over the input matrix, in some cases, the filter matrix does not fit the input matrix perfectly, when the filter matrix does not fit the input matrix perfectly we apply padding.
When we pad the input matrix with zero values is called the same padding and instead of padding if we discard the region of input matrix which does not fit well with the filter matrix then it is called valid padding.
Let’s say we performing an image classification task. First, we feed the image as input to the network and perform the convolution operation. The convolution operation extracts the important features from the image and produces the feature map. Then we feed this feature map to the fully connected layer which performs the classification task.