MCPcopy Create free account
hub / github.com/DIVE128/DMVSNet / classification_loss

Function classification_loss

loss.py:198–209  ·  view source on GitHub ↗
(prob_volume, depth_values, interval, depth_gt, mask, weight)

Source from the content-addressed store, hash-verified

196 return loss
197
198def classification_loss(prob_volume, depth_values, interval, depth_gt, mask, weight):
199 depth_gt_volume = depth_gt.unsqueeze(1).expand_as(depth_values) # (b, d, h, w)
200
201 gt_index_volume = (
202 ((depth_values - interval / 2) <= depth_gt_volume).float() * ((depth_values + interval / 2) > depth_gt_volume).float())
203
204 NEAR_0 = 1e-4 # Prevent overflow
205 prob_volume = torch.where(prob_volume <= 0.0, torch.zeros_like(prob_volume) + NEAR_0, prob_volume)
206
207 loss = -torch.sum(gt_index_volume * torch.log(prob_volume), dim=1)[mask].mean()
208 loss = loss * weight
209 return loss
210
211
212def gfocal_loss(prob_volume, depth_values, interval, depth_gt, mask, weight, gamma, alpha):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected