Skip to content
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

Merged
merged 8 commits into from
Dec 2, 2021
Merged

Feature/losses #2

merged 8 commits into from
Dec 2, 2021

Conversation

naurlaunim
Copy link
Collaborator

No description provided.

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
Copy link
Owner

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

##############################################################################
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лямбды тут не нужно использовать. ты ж можешь просто присвоить саму функцию с лоссом.

mrybakova and others added 4 commits December 1, 2021 14:13
# Conflicts:
#	models/losses.py
#	models/mesh_classifier.py
@IvanHahan IvanHahan merged commit de085bb into master Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants