MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / CrossEntropyLoss2d

Class CrossEntropyLoss2d

loss/utils.py:121–134  ·  view source on GitHub ↗

Cross Entroply NLL Loss

Source from the content-addressed store, hash-verified

119
120
121class CrossEntropyLoss2d(nn.Module):
122 """
123 Cross Entroply NLL Loss
124 """
125
126 def __init__(self, weight=None, ignore_index=cfg.DATASET.IGNORE_LABEL,
127 reduction='mean'):
128 super(CrossEntropyLoss2d, self).__init__()
129 logx.msg("Using Cross Entropy Loss")
130 self.nll_loss = nn.NLLLoss(weight, reduction=reduction,
131 ignore_index=ignore_index)
132
133 def forward(self, inputs, targets, do_rmi=None):
134 return self.nll_loss(F.log_softmax(inputs, dim=1), targets)
135
136
137def customsoftmax(inp, multihotmask):

Callers 1

get_lossFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected