kevinzakka / pytorch-goodies

PyTorch Boilerplate For Research
603 stars 71 forks source link

error by using jaccard_loss #6

Open EnQing626 opened 5 years ago

EnQing626 commented 5 years ago

Very thanks for your code. When I use the "jaccard_loss" function, some error happened: Too many indices for tensor of dimension 2 in line 110.(The num_classes is 1)

My input size of true is 3177 and the input size of logits is 3177. Can you help me to solve the problem~? Thanks

mfmezger commented 4 years ago

Hi,

can you try changing the line for the true_1_hot, and adding a cast to int64.

Like this

true_1_hot = torch.eye(num_classes)[true.squeeze(1).to(torch.int64)]

EnQing626 commented 4 years ago

Hi,

can you try changing the line for the true_1_hot, and adding a cast to int64.

Like this

true_1_hot = torch.eye(num_classes)[true.squeeze(1).to(torch.int64)]

It works for me. Thanks for your reply :)