Size mismatch in fully connected layers
I build the following simply model in pytorch as a first run and I am gettign a size mismatch error that does not make sense as out_feat always equals in_feat for the subsequent layer...
class Network(nn.Module):
    
    def __init__(self):
        super(Network,self).__init__()
        #first linear block


        self.fc1=nn.Linear(32,1024)
        self.b1=nn.BatchNorm1d(1024)
        
        #Two Linear 1
        self.fc2=nn.Linear(1024,1024)
        self.b2=nn.BatchNorm1d(1024)
        self.fc3=nn.Linear(1024,1024)
        self.b3=nn.BatchNorm1d(1024)
                
        #Two Linear 2
        self.fc4=nn.Linear(1024,1024)
        self.b4=nn.BatchNorm1d(1024)
        self.fc5=nn.Linear(1024,1024)
        self.b5=nn.BatchNorm1d(1024)        
        
        #Final Linear Layer
        self.fc6=nn.Linear(1024,48)
        
        
    def forward(self,x):
        x1=self.fc1(x)
        x1=self.b1(x1)
        x1=nn.ReLU(x1)
        
        x2=self.fc2(x1)
        x2=self.b2(x2)
        x2=nn.ReLU(x2)
        x2=self.fc3(x2)
        x2=self.b3(x2)
        x2=nn.ReLU(x2)
        
        x3=x1+x2
        
        x4=self.fc4(x3)
        x4=self.b4(x4)
        x4=nn.ReLU(x4)
        x4=self.fc5(x4)
        x4=self.b5(x4)
        x4=nn.ReLU(x4)
        
        x5=x3+x4
        
        x6=self.fc6(x5)
        
        return x6

model=Network()
zeros=np.zeros((1,32))
outputs=model(torch.FloatTensor(zeros))
RuntimeError: size mismatch, m1: [1 x 32], m2: [1024 x 32] at ..\aten\src\TH/generic/THTensorMath.cpp:41

I do not understand how I am getting this error when all the dimensions match does anyone see the issue?
=================================================================
Layer (type:depth-idx)                   Param #
=================================================================
├─Linear: 1-1                            33,792
├─BatchNorm1d: 1-2                       4,096
├─Linear: 1-3                            1,049,600
├─BatchNorm1d: 1-4                       4,096
├─Linear: 1-5                            1,049,600
├─BatchNorm1d: 1-6                       4,096
├─Linear: 1-7                            1,049,600
├─BatchNorm1d: 1-8                       4,096
├─Linear: 1-9                            1,049,600
├─BatchNorm1d: 1-10                      4,096
├─Linear: 1-11                           49,200
=================================================================
Total params: 4,301,872
Trainable params: 4,301,872
Non-trainable params: 0

here is model summary

Batch normalization works when batch size is greater than 1, so an input of shape (1, 32) won't work. Try a larger batch size, like 2.
Moreover, you're trying to use ReLU in the form x = nn.ReLU(x). This is wrong, as nn.ReLU is a layer. This line of code returns you the ReLU layer itself rather than a tensor. Either define nn.ReLU() layers in your init method, or use F.relu(x) or nn.ReLU()(x). Like so:
import torch
from torch import nn
import torch.nn.functional as F

class Network(nn.Module):
    def __init__(self):
        super(Network,self).__init__()
        #first linear block

        self.fc1=nn.Linear(32,1024)
        self.b1=nn.BatchNorm1d(1024)
        
        #Two Linear 1
        self.fc2=nn.Linear(1024,1024)
        self.b2=nn.BatchNorm1d(1024)
        self.fc3=nn.Linear(1024,1024)
        self.b3=nn.BatchNorm1d(1024)
                
        #Two Linear 2
        self.fc4=nn.Linear(1024,1024)
        self.b4=nn.BatchNorm1d(1024)
        self.fc5=nn.Linear(1024,1024)
        self.b5=nn.BatchNorm1d(1024)        
        
        #Final Linear Layer
        self.fc6=nn.Linear(1024,48)
        
        
    def forward(self,x):
        x1=self.fc1(x)
        x1=self.b1(x1)
        x1=F.relu(x1)
        
        x2=self.fc2(x1)
        x2=self.b2(x2)
        x2=F.relu(x2)
        x2=self.fc3(x2)
        x2=self.b3(x2)
        x2=F.relu(x2)
        
        x3=x1+x2
        
        x4=self.fc4(x3)
        x4=self.b4(x4)
        x4=F.relu(x4)
        x4=self.fc5(x4)
        x4=self.b5(x4)
        x4=F.relu(x4)
        
        x5=x3+x4
        
        x6=self.fc6(x5)
        
        return x6

model=Network()
zeros=torch.zeros((10, 32))
outputs=model(zeros)
print(outputs.shape)
# torch.Size([10, 48])

