1a73a1367fedfa8368b6c42103e60e1b370bc14a,catalyst/contrib/criterion/focal_loss.py,FocalLoss,forward,#FocalLoss#Any#Any#,11
Before Change
// TODO refactor
def forward(self, outputs, targets):
if targets.size() != outputs.size():
raise ValueError(
f"Targets and inputs must be same size. "
f"Got ({targets.size()}) and ({outputs.size()})"
)
max_val = (-outputs).clamp(min=0)
log_ = ((-max_val).exp() + (-outputs - max_val).exp()).log()
loss = outputs - outputs * targets + max_val + log_
invprobs = F.logsigmoid(-outputs * (targets * 2.0 - 1.0))
After Change
if cls == self.ignore:
continue
cls_label_target = targets[..., cls].long()
cls_label_input = logits[..., cls]
loss += sigmoid_focal_loss(
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
Project Name: Scitator/catalyst
Commit Name: 1a73a1367fedfa8368b6c42103e60e1b370bc14a
Time: 2019-04-19
Author: scitator@gmail.com
File Name: catalyst/contrib/criterion/focal_loss.py
Class Name: FocalLoss
Method Name: forward
Project Name: rusty1s/pytorch_geometric
Commit Name: f8c40c1d576bc4e1c4edd51b288a7e398b37f5ce
Time: 2018-12-12
Author: matthias.fey@tu-dortmund.de
File Name: torch_geometric/nn/conv/graph_conv.py
Class Name: GraphConv
Method Name: forward
Project Name: facebookresearch/Horizon
Commit Name: eeafa74969995fb902bc948d1088153a6ab58155
Time: 2020-07-24
Author: czxttkl@fb.com
File Name: reagent/training/ranking/seq2slate_trainer.py
Class Name: Seq2SlateTrainer
Method Name: train