shuxinyin / nlp-loss-pytorch Goto Github PK
View Code? Open in Web Editor NEWImplementation of some unbalanced loss like focal_loss, dice_loss, DSC Loss, GHM Loss et.al
License: MIT License
Implementation of some unbalanced loss like focal_loss, dice_loss, DSC Loss, GHM Loss et.al
License: MIT License
作者,你好!GHM_loss 做文本分类的输入应该是什么?
能不能实现个circle loss,大佬
为什么dsc loss在训练时会出现nan? 同样的代码用ce loss是正常的
Papers Weighted CE Loss and Focal Loss are set to the opposite
Thank you very much for your summary of the loss function in the field of NLP. And, I have a question about BinaryDSCLoss. I sincerely hope you can take time to answer my doubts.
This is your code:
def forward(self, logits, targets):
probs = torch.sigmoid(logits)
probs = torch.gather(probs, dim=1, index=targets.unsqueeze(1))
targets = targets.unsqueeze(dim=1)
pos_mask = (targets == 1).float()
neg_mask = (targets == 0).float()
pos_weight = pos_mask * ((1 - probs) ** self.alpha) * probs
pos_loss = 1 - (2 * pos_weight + self.smooth) / (pos_weight + 1 + self.smooth)
neg_weight = neg_mask * ((1 - probs) ** self.alpha) * probs
neg_loss = 1 - (2 * neg_weight + self.smooth) / (neg_weight + self.smooth)
loss = pos_loss + neg_loss
loss = loss.mean()
return loss
From the above code, we can see that you calculate loss for positive and negative examples respectively. But it doesn't seem to be calculated in the original paper.
Is this your improvement?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.