bob.ip.binseg.models.losses

Loss implementations

Functions

weak_script_method(x)

Classes

HEDSoftJaccardBCELogitsLoss([alpha, …])

Implements Equation 3 in [IGLOVIKOV-2018] for the hed network.

HEDWeightedBCELogitsLoss([weight, …])

Implements Equation 2 in [HE-2015].

MixJacLoss([lambda_u, jacalpha, …])

param lambda_u

determines the weighting of SoftJaccard and BCE.

SoftJaccardBCELogitsLoss([alpha, …])

Implements Equation 3 in [IGLOVIKOV-2018].

WeightedBCELogitsLoss([weight, …])

Implements Equation 1 in [MANINIS-2016].

bob.ip.binseg.models.losses.weak_script_method(x)[source]
class bob.ip.binseg.models.losses.WeightedBCELogitsLoss(weight=None, size_average=None, reduce=None, reduction='mean', pos_weight=None)[source]

Bases: torch.nn.modules.loss._Loss

Implements Equation 1 in [MANINIS-2016]. Based on torch.nn.BCEWithLogitsLoss.

Calculate sum of weighted cross entropy loss.

forward(input, target, masks=None)[source]
Parameters
Returns

Return type

torch.Tensor

class bob.ip.binseg.models.losses.SoftJaccardBCELogitsLoss(alpha=0.7, size_average=None, reduce=None, reduction='mean', pos_weight=None)[source]

Bases: torch.nn.modules.loss._Loss

Implements Equation 3 in [IGLOVIKOV-2018]. Based on torch.nn.BCEWithLogitsLoss.

alpha

determines the weighting of SoftJaccard and BCE. Default: 0.7

Type

float

forward(input, target, masks=None)[source]
Parameters
Returns

Return type

torch.Tensor

class bob.ip.binseg.models.losses.HEDWeightedBCELogitsLoss(weight=None, size_average=None, reduce=None, reduction='mean', pos_weight=None)[source]

Bases: torch.nn.modules.loss._Loss

Implements Equation 2 in [HE-2015]. Based on torch.nn.modules.loss.BCEWithLogitsLoss.

Calculate sum of weighted cross entropy loss.

forward(inputlist, target, masks=None)[source]
Parameters
Returns

Return type

torch.Tensor

class bob.ip.binseg.models.losses.HEDSoftJaccardBCELogitsLoss(alpha=0.3, size_average=None, reduce=None, reduction='mean', pos_weight=None)[source]

Bases: torch.nn.modules.loss._Loss

Implements Equation 3 in [IGLOVIKOV-2018] for the hed network. Based on torch.nn.BCEWithLogitsLoss.

alpha

determines the weighting of SoftJaccard and BCE. Default: 0.3

Type

float

forward(inputlist, target, masks=None)[source]
Parameters
Returns

Return type

torch.Tensor

class bob.ip.binseg.models.losses.MixJacLoss(lambda_u=100, jacalpha=0.7, size_average=None, reduce=None, reduction='mean', pos_weight=None)[source]

Bases: torch.nn.modules.loss._Loss

Parameters

lambda_u (int) – determines the weighting of SoftJaccard and BCE.

forward(input, target, unlabeled_input, unlabeled_traget, ramp_up_factor)[source]
Parameters
Returns

Return type

list