Thanks for your reply. Sorry to disturb you again.For the last question, I had set  ignore_index to -1 .
criterion_CE = nn.CrossEntropyLoss(ignore_index=-1).cuda()
…
labels[(0.3 <= labels) & (labels <= 0.7)] = -1
…
loss = criterion_CE(out, torch.squeeze(labels).long())
How could I fix this?