Convolutional neural networks - What is done first? Padding or convolving?
Suppose the code below :
network = lasagne.layers.InputLayer(shape=(batch_size, 1, 11, 11), input_var=input_var)
network = lasagne.layers.Conv2DLayer(incoming=network, num_filters=20, filter_size=(3, 3), stride=1, pad=3)
network = lasagne.layers.Conv2DLayer(incoming=network, num_filters=20, filter_size=(3, 3), stride=1, pad=2)
network = lasagne.layers.MaxPool2DLayer(incoming=network, pool_size=(2, 2))
The input layer has the dimension $11;11;1$.
Consider the following function : $\frac{W - F + 2P}{S} + 1$
$W$ = input dimension
$F$ = filter size
$P$ = padding
$S$ = stride
Therefore, The first convolution layer will output the dimension : $11 - 3 + 2*3 + 1$ $15$
Output Dimension : 15x15x1
QUESTION
When the filter/kernel of the layer goes through the input, does it PAD it first and then convolve or does it convolve in the input first and then adds the padding ? Because if the convolving is done first, then the border is lost to the next layer, correct? So would it be needed to pad the input before the first convolutional layer to avoid losing any border at all?