Hello, I am having a channel issue. Can anyone please help me out with the same? Thanks in advance.
#CNN architecture
class classifier(nn.Module):
    def __init__(self):
        super(classifier,self).__init__()
        self.block1=self.conv_block(cin=1,cout=256,dropout=0.1,kernel_size=5,padding=1,stride=2)
        self.block2=self.conv_block(cin=256,cout=256,dropout=0.1,kernel_size=3,padding=1,stride=1)
        self.block3=self.conv_block(cin=256,cout=128,dropout=0.1,kernel_size=3,padding=1,stride=1)
        self.lastcnn=nn.Conv2d(in_channels=128,out_channels=102,kernel_size=15,padding=0,stride=1)
        
        self.maxpool=nn.MaxPool2d(kernel_size=2,stride=2)
        
    def forward(self,x):
        x=self.block1(x)
        x=self.maxpool(x)
        
        x=self.block2(x)
        x=self.maxpool(x)
        
        x=self.block3(x)
        x=self.maxpool(x)
        
        x=self.lastcnn(x)
        x = x.flatten(start_dim=1)
        return x
        
    def conv_block(self,cin,cout,dropout,**kwargs):
        seq_block=nn.Sequential(
                    nn.Conv2d(in_channels=cin,out_channels=cout,**kwargs),
                    nn.BatchNorm2d(num_features=cout),
                    nn.ReLU(),
                    nn.Dropout2d(p=dropout)            
        )
        return seq_block

Training Block
print('Training')
epochs=10
for epoch in tqdm(range(epochs)):
        train_loss,train_acc=0,0
        model.train()
        for inputs,targets in train_loader:
            #inputs,targets=inputs.to(device),targets.to(device)
            optimizer.zero_grad()
            print(inputs.shape)
            y_pred=model(inputs)
            #print(y_pred.shape)
            loss=criterion(y_pred,targets)
            accuracy=accuracy(y_pred,targets)
            loss.backward()
            optimizer.step()
            train_loss+=loss.item()
            train_acc+=accuracy.item()
        loss_stats['train'].append(train_loss/len(train_loader))
        accuracy_stats['train'].append(accuracy_loss/len(train_loader))
        print(f'Epoch {e+0:02}: | Train Loss: {train_loss/len(train_loader):.3f} | Train Acc: {train_acc/len(train_loader):.3f}')

Error
RuntimeError                              Traceback (most recent call last)
<ipython-input-125-16c3c99a7be2> in <module>
      8             optimizer.zero_grad()
      9             print(inputs.shape)
---> 10             y_pred=model(inputs)
     11             print(y_pred.shape)
     12             loss=criterion(y_pred,targets)

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

<ipython-input-122-87a5f180cde4> in forward(self, x)
     11 
     12     def forward(self,x):
---> 13         x=self.block1(x)
     14         x=self.maxpool(x)
     15 

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

~\Anaconda3\lib\site-packages\torch\nn\modules\container.py in forward(self, input)
     98     def forward(self, input):
     99         for module in self:
--> 100             input = module(input)
    101         return input
    102 

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

~\Anaconda3\lib\site-packages\torch\nn\modules\conv.py in forward(self, input)
    351 
    352     def forward(self, input):
--> 353         return self._conv_forward(input, self.weight)
    354 
    355 class Conv3d(_ConvNd):

~\Anaconda3\lib\site-packages\torch\nn\modules\conv.py in _conv_forward(self, input, weight)
    348                             _pair(0), self.dilation, self.groups)
    349         return F.conv2d(input, weight, self.bias, self.stride,
--> 350                         self.padding, self.dilation, self.groups)
    351 
    352     def forward(self, input):

RuntimeError: Given groups=1, weight of size [256, 1, 5, 5], expected input[4, 3, 256, 256] to have 1 channels, but got 3 channels instead