yhygao/focusnet-v2

Unable to get repr for class 'torch.tensor'

Closed this issue · 2 comments

Hi, When I train with my own data and compute the dice and focal loss, I get the following error:

Unable to get repr for <class 'torch.Tensor'>, when I use the below code:
preds = preds.permute(0, 2, 3, 4, 1).contiguous().view(-1, C)

Have you ever encountered this problem, how should I solve it?

Hi, I didn't get this error before.
One possible reason to have this error is the number of classes. You need to make sure the number of output channel of the network (i.e. preds) to match with the number of classes C.
One post that might help: https://stackoverflow.com/questions/51009687/pytorch-unable-to-get-repr-for-class-torch-tensor

Yeah, it's done, thank you!