It’s my size of outputs and labels.
with torch.set_grad_enabled(phase == 'train'):
                    outputs = model(inputs)
                    #print(outputs.size())
                    #print(labels.size())
                    labels = torch.argmax(labels, dim=1)
                    #print(labels.size())
                    _, preds = torch.max(outputs, 1)
                    loss = criterion(outputs, labels)
torch.Size([4, 6])
torch.Size([4, 256, 256])

use
labels = torch.argmax(labels,dim=1)

but can’t create the 1D  target tensor.