Hi,
I study image classification model, and try to make mown model. All layers in my model seems to have matched size between pre/post layer-connections.
Bellow is my summary of model;

    Layer (type)               Output Shape         Param #

================================================================
        Conv2d-1          [-1, 9, 110, 110]             684
     AvgPool2d-2          [-1, 9, 106, 106]               0
        Conv2d-3            [-1, 3, 52, 52]             246
     AvgPool2d-4            [-1, 3, 50, 50]               0
        Conv2d-5            [-1, 3, 25, 25]              12
     AvgPool2d-6            [-1, 3, 23, 23]               0
        Linear-7                  [-1, 529]         840,052
        Linear-8                   [-1, 59]          31,270
        Linear-9                    [-1, 5]             300

================================================================
Total params: 872,564
Trainable params: 872,564
Non-trainable params: 0

Input size (MB): 0.57
Forward/backward pass size (MB): 1.75
Params size (MB): 3.33
Estimated Total Size (MB): 5.66

And batch size is 32 in now, then run training met an error at Linear-7;
RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x19950 and 1587x529)
The mat2 is the (3x23x23=1587)x529, PyTorch generates parameters correctly. I use torch.flatten(start_dim=1), my understanding is that start_dim=0 is about a batch, so correctly flattening is done.
Does anyone know how “19950” comes from ?
My understanding is that comes from previous layer, and multiply-added by mat1, mat2, and biases, previous layer is;
nn.AvgPool2d(kernel_size=(3, 3), stride=1)
–
IAMAl