FocalLoss() gamma and alpha default values
This commit is contained in:
parent
208b9a73fe
commit
418269d739
2
train.py
2
train.py
|
@ -32,7 +32,7 @@ hyp = {'giou': 3.54, # giou loss gain
|
||||||
'lrf': -4., # final LambdaLR learning rate = lr0 * (10 ** lrf)
|
'lrf': -4., # final LambdaLR learning rate = lr0 * (10 ** lrf)
|
||||||
'momentum': 0.937, # SGD momentum
|
'momentum': 0.937, # SGD momentum
|
||||||
'weight_decay': 0.000484, # optimizer weight decay
|
'weight_decay': 0.000484, # optimizer weight decay
|
||||||
'fl_gamma': 0.5, # focal loss gamma
|
'fl_gamma': 1.5, # focal loss gamma
|
||||||
'hsv_h': 0.0138, # image HSV-Hue augmentation (fraction)
|
'hsv_h': 0.0138, # image HSV-Hue augmentation (fraction)
|
||||||
'hsv_s': 0.678, # image HSV-Saturation augmentation (fraction)
|
'hsv_s': 0.678, # image HSV-Saturation augmentation (fraction)
|
||||||
'hsv_v': 0.36, # image HSV-Value augmentation (fraction)
|
'hsv_v': 0.36, # image HSV-Value augmentation (fraction)
|
||||||
|
|
|
@ -340,7 +340,7 @@ def wh_iou(wh1, wh2):
|
||||||
class FocalLoss(nn.Module):
|
class FocalLoss(nn.Module):
|
||||||
# Wraps focal loss around existing loss_fcn() https://arxiv.org/pdf/1708.02002.pdf
|
# Wraps focal loss around existing loss_fcn() https://arxiv.org/pdf/1708.02002.pdf
|
||||||
# i.e. criteria = FocalLoss(nn.BCEWithLogitsLoss(), gamma=2.5)
|
# i.e. criteria = FocalLoss(nn.BCEWithLogitsLoss(), gamma=2.5)
|
||||||
def __init__(self, loss_fcn, gamma=0.5, alpha=1):
|
def __init__(self, loss_fcn, gamma=1.5, alpha=0.25):
|
||||||
super(FocalLoss, self).__init__()
|
super(FocalLoss, self).__init__()
|
||||||
self.loss_fcn = loss_fcn
|
self.loss_fcn = loss_fcn
|
||||||
self.gamma = gamma
|
self.gamma = gamma
|
||||||
|
|
Loading…
Reference in New Issue