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

Function customsoftmax

loss/utils.py:137–147  ·  view source on GitHub ↗

Custom Softmax

(inp, multihotmask)

Source from the content-addressed store, hash-verified

135
136
137def customsoftmax(inp, multihotmask):
138 """
139 Custom Softmax
140 """
141 soft = F.softmax(inp)
142 # This takes the mask * softmax ( sums it up hence summing up the classes
143 # in border then takes of summed up version vs no summed version
144 return torch.log(
145 torch.max(soft,
146 (multihotmask * (soft * multihotmask).sum(1, keepdim=True)))
147 )
148
149
150class ImgWtLossSoftNLL(nn.Module):

Callers 1

custom_nllMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected