-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/losses #2
Conversation
not_padding = not_padding.unsqueeze(0) | ||
pred_class = pred_class[not_padding] | ||
pred_class = pred_class.reshape([1, 2, int(pred_class.size()[0] / 2)]) | ||
return label_class, pred_class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
шот сложное тут творишь. плюс, захардкожены классы. ты либо все сделай флат, отфильтруй -1, а потом экспанд дименшин сделай, чтобы количество размерностей подходящее было. Либо в лоссах делай умножение на 0, в позициях для -1
loss_dice = lambda out, labels: dice_loss(labels.unsqueeze(1).unsqueeze(-1), out.unsqueeze(-1)) | ||
device = torch.device('cuda:{}'.format(opt.gpu_ids[0])) if opt.gpu_ids else torch.device('cpu') | ||
loss_ce = lambda out, labels: ce_loss(labels.squeeze(), out.squeeze().transpose(0,1), weights=torch.FloatTensor([0.5, 2]).to(device)) | ||
loss = lambda out, labels: loss_ce(out, labels) + loss_dice(out, labels) | ||
return loss | ||
|
||
############################################################################## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лямбды тут не нужно использовать. ты ж можешь просто присвоить саму функцию с лоссом.
# Conflicts: # models/losses.py # models/mesh_classifier.py
No description provided.