Using a target size (torch.Size([100, 1])) that is different to the input size (torch.Size([100, 100])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size

I am running the following code for a simple problem, and the issue is that my outputs shape depends on the batch size which is causing issues and giving the warning. I am predicting a single scalar using a vector of dimension 26
Please can you guide me where am I making a mistake in this issue :

df = pd.read_csv(r'D:\SAA_prime\saa\new_dataset1.csv')
df.shape # [40964,26]
scr = pd.read_csv('D:\SAA_prime\saa\scr_new_data1.csv')
scr.shape #(40964, 1)
inputs = torch.from_numpy(np.array(df.iloc[:, :-1])).type(torch.float32)
inputs.shape #torch.Size([40964, 25])
targets = np.array(scr).reshape(40964,1)
targets = torch.from_numpy(targets).type(torch.float32)
targets.shape#torch.Size([40964, 1])
dataset = TensorDataset(inputs, targets)
train_size = int(0.8 * len(dataset))
test_size = len(dataset) - train_size
train_dataset, test_dataset =, [train_size, test_size])
batch_size = 10
trainloader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True)
class scr_model(torch.nn.Module):
    def __init__(self):
        self.W = torch.nn.Parameter(torch.randn((25,25)))
        self.m = torch.nn.Parameter(torch.randn((25,1)))
        self.b = torch.nn.Parameter(torch.randn((1)))

    def forward(self, x):
        return (self.b + x @ self.m  +  x @ self.W @ x.t())  
model = scr_model()

for x,y in trainloader:
    preds = model(x)
    print("Prediction is :\n",preds.shape)
    print("\nActual targets is :\n",y.shape)

Prediction is :
torch.Size([10, 10])

Actual targets is :
torch.Size([10, 1])

I have tried to debug this code many times from different angles but I am unable to find the cause of the error. Any help will be much appreciated!

Cross-post from here with a clarifying question.
It’s currently unclear how you are interpreting the used operation as you are explicitly creating the batch size - dependent output in your model.