Can someone explain the layers code in the following pytorch neural network
The neural network is a pytorch implementation of the NVIDIA model for self driving cars.
Here I did not understand the first layer of the linear layers, the following is the line.
'nn.Linear(in_features=64 * 2 * 33, out_features=100)'
I can understand that 64 is the output of previous layer and 2 is number of flattened layers (if im not wrong).
Now my question is what's the purpose of '33'?

class NetworkDense(nn.Module):
def __init__(self):
    super(NetworkDense, self).__init__()
    self.conv_layers = nn.Sequential(
        nn.Conv2d(3, 24, 5, stride=2),
        nn.ELU(),
        nn.Conv2d(24, 36, 5, stride=2),
        nn.ELU(),
        nn.Conv2d(36, 48, 5, stride=2),
        nn.ELU(),
        nn.Conv2d(48, 64, 3),
        nn.ELU(),
        nn.Conv2d(64, 64, 3),
        nn.Dropout(0.25)
    )
    self.linear_layers = nn.Sequential(
        nn.Linear(in_features=64 * 2 * 33, out_features=100),
        nn.ELU(),
        nn.Linear(in_features=100, out_features=50),
        nn.ELU(),
        nn.Linear(in_features=50, out_features=10),
        nn.Linear(in_features=10, out_features=1)
    )
    
def forward(self, input):  
    input = input.view(input.size(0), 3, 70, 320)
    output = self.conv_layers(input)
    output = output.view(output.size(0), -1)
    output = self.linear_layers(output)
    return output


It comes from your first input shape.
input = input.view(input.size(0), 3, 70, 320)
Think about it as an image with a size of (70, 320). If we pass that image to the first conv2d, then it will become (33, 158)..., and at last, if it all passes the conv layer, its shape will become (2, 33).
So, how to calculate these numbers?
It goes like:
(length - (kernel_size - stride)) // stride
Now let's just think about how the 70 will be changed. The first conv2d has a kernel size of 5 with stride 2. So 70 will be like:
(70 - (5 - 2)) // 2 =&gt; 33, then for the rest:
(33 - (5 - 2)) // 2 =&gt; 15
(15 - (5 - 2)) // 2 =&gt; 6
(6 - (3 - 1)) // 1` =&gt; 4
(4 - (3 - 1)) // 1` =&gt; 2

It's the same as the other length, 320 will become 33.
