Hello
i am getting the error above in “criterion.forward” line , i tried another criterion functions but they give the same error
criterion = nn.NLLLoss()
optimizer = torch.optim.Adam(model.parameters(),lr=learning_rate,weight_decay=1e-5)
test_op = model(test_img.cuda())
criterion.forward(test_lb.cuda(),test_op)
Hello,
Could you try the following code:
criterion = nn.NLLLoss()
optimizer = torch.optim.Adam(model.parameters(). lr=learning_rate, weight_decay=1e-5)
test_op = model(test_img.cuda())
criterion(test_op, test_lb.cuda())
hi
this error appears
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 ‘target’
test_lb.cuda()->test_lb.to(torch.long).cuda()
thank you
i am gitting this error now
RuntimeError: 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: : [2, 1, 256, 256]