I’ve solved the problem …
The problem was in ‘transforms.Grayscale (num_output_channels = 1)’
I deleted ‘transforms.Grayscale (num_output_channels = 1)’ and added ‘np.float32’ as shown below.
class trainDataset(torch.utils.data.Dataset):
    def __init__(self, data, target, transform=None):
        self.data = data.astype(np.float32)
        self.target = target.astype(np.float32)
        self.transform = transform
        
    def __getitem__(self, index):
        x = self.data[index]
        y = self.target[index]
        
        if self.transform:
            x = self.transform(x)
            y = self.transform(y)
            
        return x,y
    
    def __len__(self):
        return len(self.data)