BCEWithLogitsLoss

class dragon.vm.torch.nn.BCEWithLogitsLoss(
  weight=None,
  size_average=None,
  reduce=None,
  reduction='valid',
  pos_weight=None
)[source]

Compute the sigmoid cross entropy with contiguous targets.

Examples:

m = torch.nn.BCEWithLogitsLoss()
loss = m(torch.randn(2, 1), torch.tensor([0., 1.], 'float32'))

__init__

BCEWithLogitsLoss.__init__(
  weight=None,
  size_average=None,
  reduce=None,
  reduction='valid',
  pos_weight=None
)[source]

Create a BCEWithLogitsLoss module.

Parameters:
  • weight (dragon.vm.torch.Tensor, optional) – The weight for each class.
  • size_average (bool, optional) – True to set the reduction to ‘mean’.
  • reduce (bool, optional) – True to set the reduction to ‘sum’ or ‘mean’.
  • reduction ({'none', 'mean', 'sum', 'valid'}, optional) – The reduce method.