Output shape from each layer in a Sequential model in pytorch

SpinCNN(
(conv_layer): Sequential(
(0): Conv2d(30, 15, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(1): BatchNorm2d(15, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace=True)
(3): Conv2d(15, 30, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(4): ReLU(inplace=True)
(5): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(6): Conv2d(30, 60, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(7): BatchNorm2d(60, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(8): ReLU(inplace=True)
(9): Conv2d(60, 60, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(10): ReLU(inplace=True)
(11): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(12): Dropout2d(p=0.05, inplace=False)
(13): Conv2d(60, 120, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(14): BatchNorm2d(120, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(15): ReLU(inplace=True)
(16): Conv2d(120, 120, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(17): ReLU(inplace=True)
(18): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
)
(fc_spin_layer1): Sequential(
(0): Dropout(p=0.1, inplace=False)
(1): Linear(in_features=60, out_features=20, bias=True)
(2): ReLU(inplace=True)
)
(fc_spin_layer2): Sequential(
(0): Dropout(p=0.1, inplace=False)
(1): Linear(in_features=80, out_features=20, bias=True)
(2): ReLU(inplace=True)
)
(fc_spin_layer3): Sequential(
(0): Dropout(p=0.1, inplace=False)
(1): Linear(in_features=80, out_features=20, bias=True)
(2): ReLU(inplace=True)
)
(fc_spin_layer4): Sequential(
(0): Dropout(p=0.1, inplace=False)
(1): Linear(in_features=80, out_features=20, bias=True)
(2): ReLU(inplace=True)
)
(fc_out): Sequential(
(0): Dropout(p=0.1, inplace=False)
(1): Linear(in_features=80, out_features=16, bias=True)
)
)
Hello friends. Above is the model structure of a deep learning model . The summary for the above model: summary(model, (30, 15, 15)) is,

---------------------------------------------------------------
        Layer (type)               Output Shape         Param #
================================================================
            Conv2d-1           [-1, 15, 15, 15]           4,065
       BatchNorm2d-2           [-1, 15, 15, 15]              30
              ReLU-3           [-1, 15, 15, 15]               0
            Conv2d-4           [-1, 30, 15, 15]           4,080
              ReLU-5           [-1, 30, 15, 15]               0
         MaxPool2d-6             [-1, 30, 7, 7]               0
            Conv2d-7             [-1, 60, 7, 7]          16,260
       BatchNorm2d-8             [-1, 60, 7, 7]             120
              ReLU-9             [-1, 60, 7, 7]               0
           Conv2d-10             [-1, 60, 7, 7]          32,460
             ReLU-11             [-1, 60, 7, 7]               0
        MaxPool2d-12             [-1, 60, 3, 3]               0
        Dropout2d-13             [-1, 60, 3, 3]               0
           Conv2d-14            [-1, 120, 3, 3]          64,920
      BatchNorm2d-15            [-1, 120, 3, 3]             240
             ReLU-16            [-1, 120, 3, 3]               0
           Conv2d-17            [-1, 120, 3, 3]         129,720
             ReLU-18            [-1, 120, 3, 3]               0
        MaxPool2d-19            [-1, 120, 1, 1]               0
          Dropout-20                   [-1, 60]               0
           Linear-21                   [-1, 20]           1,220
             ReLU-22                   [-1, 20]               0
          Dropout-23                   [-1, 80]               0
           Linear-24                   [-1, 20]           1,620
             ReLU-25                   [-1, 20]               0
          Dropout-26                   [-1, 80]               0
           Linear-27                   [-1, 20]           1,620
             ReLU-28                   [-1, 20]               0
          Dropout-29                   [-1, 80]               0
           Linear-30                   [-1, 20]           1,620
             ReLU-31                   [-1, 20]               0
          Dropout-32                   [-1, 80]               0
           Linear-33                   [-1, 16]           1,296
================================================================
Total params: 259,271
Trainable params: 259,271
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.03
Forward/backward pass size (MB): 0.36
Params size (MB): 0.99
Estimated Total Size (MB): 1.37
----------------------------------------------------------------

where Half_width =60 and layer_width = 20

I am unable to understand why the shape of the output within each convolution block is constant.

It is because you are using kernel_size = 3, stride=1, and padding=1. This will retain the image dimension since

output_size = (input_size + 2 * padding -kernel_size)/ stride +1

Hence, output_size = input_size. Try changing one of the parameters like stride or padding and the output dimensions will change.

Hope that helps!