yhygao / focusnet-v2

28 stars 4 forks source link

Unable to get repr for class 'torch.tensor' #1

Closed Cocofeat closed 2 years ago

Cocofeat commented 2 years ago

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?

yhygao commented 2 years ago

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

Cocofeat commented 2 years ago

Yeah, it's done, thank you!