MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / forward

Method forward

sat/sgm/modules/autoencoding/lpips/loss/lpips.py:42–55  ·  view source on GitHub ↗
(self, input, target)

Source from the content-addressed store, hash-verified

40 return model
41
42 def forward(self, input, target):
43 in0_input, in1_input = (self.scaling_layer(input), self.scaling_layer(target))
44 outs0, outs1 = self.net(in0_input), self.net(in1_input)
45 feats0, feats1, diffs = {}, {}, {}
46 lins = [self.lin0, self.lin1, self.lin2, self.lin3, self.lin4]
47 for kk in range(len(self.chns)):
48 feats0[kk], feats1[kk] = normalize_tensor(outs0[kk]), normalize_tensor(outs1[kk])
49 diffs[kk] = (feats0[kk] - feats1[kk]) ** 2
50
51 res = [spatial_average(lins[kk].model(diffs[kk]), keepdim=True) for kk in range(len(self.chns))]
52 val = res[0]
53 for l in range(1, len(self.chns)):
54 val += res[l]
55 return val
56
57
58class ScalingLayer(nn.Module):

Callers

nothing calls this directly

Calls 2

normalize_tensorFunction · 0.85
spatial_averageFunction · 0.85

Tested by

no test coverage detected