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

Method forward

loss/utils.py:102–118  ·  view source on GitHub ↗
(self, inputs, targets, do_rmi=None)

Source from the content-addressed store, hash-verified

100 return hist
101
102 def forward(self, inputs, targets, do_rmi=None):
103
104 if self.batch_weights:
105 weights = self.calculate_weights(targets)
106 self.nll_loss.weight = weights
107
108 loss = 0.0
109 for i in range(0, inputs.shape[0]):
110 if not self.batch_weights:
111 weights = self.calculate_weights(targets)
112 if self.fp16:
113 weights = weights.half()
114 self.nll_loss.weight = weights
115
116 loss += self.nll_loss(F.log_softmax(inputs[i].unsqueeze(0), dim=1),
117 targets[i].unsqueeze(0),)
118 return loss
119
120
121class CrossEntropyLoss2d(nn.Module):

Callers

nothing calls this directly

Calls 1

calculate_weightsMethod · 0.95

Tested by

no test coverage detected