MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / forward

Method forward

script/models/losses.py:42–57  ·  view source on GitHub ↗
(self, inputs, targets, use_hier_rgbs=False, rgb_h=None, rgb_w=None)

Source from the content-addressed store, hash-verified

40 self.lambda_u = lambda_u
41
42 def forward(self, inputs, targets, use_hier_rgbs=False, rgb_h=None, rgb_w=None):
43
44 ret = {}
45 ret['c_l'] = 0.5 * ((inputs['rgb_coarse']-targets)**2).mean()
46 if 'rgb_fine' in inputs:
47 if 'beta' not in inputs: # no transient head, normal MSE loss
48 ret['f_l'] = 0.5 * ((inputs['rgb_fine']-targets)**2).mean()
49 else:
50 ret['f_l'] = ((inputs['rgb_fine']-targets)**2/(2*inputs['beta'].unsqueeze(1)**2)).mean()
51 ret['b_l'] = 3 + torch.log(inputs['beta']).mean() # +3 to make it positive
52 ret['s_l'] = self.lambda_u * inputs['transient_sigmas'].mean()
53
54 for k, v in ret.items():
55 ret[k] = self.coef * v
56
57 return ret
58
59loss_dict = {'color': ColorLoss,
60 'nerfw': NerfWLoss}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected