I load src_image and src_label from src_dataloader and convert them into variables. Then enter the classifier and use cross entropy to calculate the loss, but this error occurs. How should I solve it?
###### Classifier A ######
        optimizer_C_A.zero_grad()

        # Classifier loss
        pred = netC_A(netG_A2B(real_A))
        loss_C = criterion_class(pred, label_A)
        loss_C.backward()

        optimizer_C.step()
        ###################################

for step, (src_image, src_label) in enumerate(src_dataloader):
    real_A = make_variable(src_image)
    label_A = make_variable(src_label.squeeze_())

def make_variable(tensor):
    """Convert Tensor to Variable."""
    if torch.cuda.is_available():
        tensor = tensor.cuda()
    return Variable(tensor)

微信图片_202006290917411015×253 23.8 KB