ValueError: Expected input batch_size (324) to match target batch_size (4)

Sir i unsqueezed both x & y…
dimensions now are–>
print(X_train.shape,y_train.shape)->torch.Size([1, 8054, 67, 50]) torch.Size([1, 8054])
print(X_test.shape,y_test.shape)-> torch.Size([1, 3968, 67, 50]) torch.Size([1, 3968])

Changed this to->

class Net(nn.Module):

def __init__(self):
    super(Net, self).__init__()
    self.conv1 = nn.Conv2d(1, 32, kernel_size=5)
    self.conv2 = nn.Conv2d(32, 20, kernel_size=5)
    self.mp = nn.MaxPool2d(2)
    self.fc = nn.Linear(2340, 2)

def forward(self, x):
    in_size = x.size(0)
    x = F.relu(self.mp(self.conv1(x.float())))
    x = F.relu(self.mp(self.conv2(x.float())))
    x = x.view(in_size, -1)  # flatten the tensor
    x = self.fc(x)
    return F.log_softmax(x,dim=1)

Now error is

RuntimeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_1468/1708038120.py in
17 optimizer.zero_grad()
18
—> 19 outputs = model(b_input_ids[None, …])
20 print(b_input_ids.shape)
21 print(b_labels.shape)

~\anaconda3\envs\for_CharBert\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101 or _global_forward_hooks or _global_forward_pre_hooks):
→ 1102 return forward_call(*input, **kwargs)
1103 # Do not call functions when jit is used
1104 full_backward_hooks, non_full_backward_hooks = [], []

~\AppData\Local\Temp/ipykernel_1468/3913028989.py in forward(self, x)
10 def forward(self, x):
11 in_size = x.size(0)
—> 12 x = F.relu(self.mp(self.conv1(x.float())))
13 x = F.relu(self.mp(self.conv2(x.float())))
14 x = x.view(in_size, -1) # flatten the tensor

~\anaconda3\envs\for_CharBert\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101 or _global_forward_hooks or _global_forward_pre_hooks):
→ 1102 return forward_call(*input, **kwargs)
1103 # Do not call functions when jit is used
1104 full_backward_hooks, non_full_backward_hooks = [], []

~\anaconda3\envs\for_CharBert\lib\site-packages\torch\nn\modules\conv.py in forward(self, input)
444
445 def forward(self, input: Tensor) → Tensor:
→ 446 return self._conv_forward(input, self.weight, self.bias)
447
448 class Conv3d(_ConvNd):

~\anaconda3\envs\for_CharBert\lib\site-packages\torch\nn\modules\conv.py in _conv_forward(self, input, weight, bias)
440 weight, bias, self.stride,
441 _pair(0), self.dilation, self.groups)
→ 442 return F.conv2d(input, weight, bias, self.stride,
443 self.padding, self.dilation, self.groups)
444

RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5], but got 5-dimensional input of size [1, 1, 8054, 67, 50] instead