RuntimeError: "log_cuda" not implemented for 'Long'

Hi Patrick,

To train my MAML, I am experimenting with loss functions. In switching from CrossEntropyLoss to KLDivLoss I got: RuntimeError: “log_cuda” not implemented for ‘Long’

My loss function takes in:

#k_way = 5
#data_shape = x.shape[2:] , where x are my input samples
#create_nshot_task_label , where y is : Label vector for n-shot task of shape [q * k, ]
and y = torch.arange(0, k, 1 / q).long()

logits = model(torch.zeros((k_way, ) + data_shape).to(device, dtype=torch.double))
loss = loss_fn(logits, create_nshot_task_label(k_way, 1).to(device))

I was hoping you could help me overcome this! Thank you!

nn.KLDivLoss expects the model output and target to have the same shape and as FloatTensors.
I guess you are passing the same targets from the nn.CrossEntropyLoss to the new criterion, which will yield this error.