Skip to content

Commit

Permalink
Change BCE loss to NFL loss in training scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ksofiyuk committed Aug 13, 2020
1 parent 90717d6 commit f026fdc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions models/sbd/hrnet18_ocr64.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from isegm.engine.trainer import ISTrainer
from isegm.model.is_hrnet_model import get_hrnet_model
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss, NormalizedFocalLossSigmoid
from isegm.model.metrics import AdaptiveIoU
from isegm.data.sbd import SBDDataset
from isegm.data.points_sampler import MultiPointSampler
Expand Down Expand Up @@ -56,7 +56,7 @@ def train(model, cfg, model_cfg, start_epoch=0):
crop_size = model_cfg.crop_size

loss_cfg = edict()
loss_cfg.instance_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_loss = NormalizedFocalLossSigmoid(alpha=0.5, gamma=2)
loss_cfg.instance_loss_weight = 1.0
loss_cfg.instance_aux_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_aux_loss_weight = 0.4
Expand Down
4 changes: 2 additions & 2 deletions models/sbd/hrnet32_ocr128.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from isegm.engine.trainer import ISTrainer
from isegm.model.is_hrnet_model import get_hrnet_model
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss, NormalizedFocalLossSigmoid
from isegm.model.metrics import AdaptiveIoU
from isegm.data.sbd import SBDDataset
from isegm.data.points_sampler import MultiPointSampler
Expand Down Expand Up @@ -56,7 +56,7 @@ def train(model, cfg, model_cfg, start_epoch=0):
crop_size = model_cfg.crop_size

loss_cfg = edict()
loss_cfg.instance_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_loss = NormalizedFocalLossSigmoid(alpha=0.5, gamma=2)
loss_cfg.instance_loss_weight = 1.0
loss_cfg.instance_aux_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_aux_loss_weight = 0.4
Expand Down
4 changes: 2 additions & 2 deletions models/sbd/hrnet48_ocr128.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from isegm.engine.trainer import ISTrainer
from isegm.model.is_hrnet_model import get_hrnet_model
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss, NormalizedFocalLossSigmoid
from isegm.model.metrics import AdaptiveIoU
from isegm.data.sbd import SBDDataset
from isegm.data.points_sampler import MultiPointSampler
Expand Down Expand Up @@ -56,7 +56,7 @@ def train(model, cfg, model_cfg, start_epoch=0):
crop_size = model_cfg.crop_size

loss_cfg = edict()
loss_cfg.instance_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_loss = NormalizedFocalLossSigmoid(alpha=0.5, gamma=2)
loss_cfg.instance_loss_weight = 1.0
loss_cfg.instance_aux_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_aux_loss_weight = 0.4
Expand Down
4 changes: 2 additions & 2 deletions models/sbd/r101_dh256.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from isegm.engine.trainer import ISTrainer
from isegm.model.is_deeplab_model import get_deeplab_model
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss
from isegm.model.losses import NormalizedFocalLossSigmoid
from isegm.model.metrics import AdaptiveIoU
from isegm.data.sbd import SBDDataset
from isegm.data.points_sampler import MultiPointSampler
Expand Down Expand Up @@ -56,7 +56,7 @@ def train(model, cfg, model_cfg, start_epoch=0):
crop_size = model_cfg.crop_size

loss_cfg = edict()
loss_cfg.instance_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_loss = NormalizedFocalLossSigmoid(alpha=0.5, gamma=2)
loss_cfg.instance_loss_weight = 1.0

num_epochs = 120
Expand Down
4 changes: 2 additions & 2 deletions models/sbd/r34_dh128.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from isegm.engine.trainer import ISTrainer
from isegm.model.is_deeplab_model import get_deeplab_model
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss
from isegm.model.losses import NormalizedFocalLossSigmoid
from isegm.model.metrics import AdaptiveIoU
from isegm.data.sbd import SBDDataset
from isegm.data.points_sampler import MultiPointSampler
Expand Down Expand Up @@ -56,7 +56,7 @@ def train(model, cfg, model_cfg, start_epoch=0):
crop_size = model_cfg.crop_size

loss_cfg = edict()
loss_cfg.instance_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_loss = NormalizedFocalLossSigmoid(alpha=0.5, gamma=2)
loss_cfg.instance_loss_weight = 1.0

num_epochs = 120
Expand Down
4 changes: 2 additions & 2 deletions models/sbd/r50_dh128.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from isegm.engine.trainer import ISTrainer
from isegm.model.is_deeplab_model import get_deeplab_model
from isegm.model.losses import SigmoidBinaryCrossEntropyLoss
from isegm.model.losses import NormalizedFocalLossSigmoid
from isegm.model.metrics import AdaptiveIoU
from isegm.data.sbd import SBDDataset
from isegm.data.points_sampler import MultiPointSampler
Expand Down Expand Up @@ -56,7 +56,7 @@ def train(model, cfg, model_cfg, start_epoch=0):
crop_size = model_cfg.crop_size

loss_cfg = edict()
loss_cfg.instance_loss = SigmoidBinaryCrossEntropyLoss()
loss_cfg.instance_loss = NormalizedFocalLossSigmoid(alpha=0.5, gamma=2)
loss_cfg.instance_loss_weight = 1.0

num_epochs = 120
Expand Down

0 comments on commit f026fdc

Please sign in to comment.