MCPcopy Create free account
hub / github.com/MiniMax-AI/VTP / forward

Method forward

vtp/utils/lpips.py:84–100  ·  view source on GitHub ↗
(self, input, target)

Source from the content-addressed store, hash-verified

82 )
83
84 def forward(self, input, target):
85 in0_input, in1_input = (self.scaling_layer(input), self.scaling_layer(target))
86 outs0, outs1 = self.net(in0_input), self.net(in1_input)
87 feats0, feats1, diffs = {}, {}, {}
88 lins = [self.lin0, self.lin1, self.lin2, self.lin3, self.lin4]
89 for kk in range(len(self.chns)):
90 feats0[kk], feats1[kk] = normalize_tensor(outs0[kk]), normalize_tensor(outs1[kk])
91 diffs[kk] = (feats0[kk] - feats1[kk]) ** 2
92
93 res = [
94 spatial_average(lins[kk].model(diffs[kk]), keepdim=True)
95 for kk in range(len(self.chns))
96 ]
97 val = res[0]
98 for l in range(1, len(self.chns)):
99 val += res[l]
100 return val
101
102
103class ScalingLayer(nn.Module):

Callers

nothing calls this directly

Calls 2

normalize_tensorFunction · 0.85
spatial_averageFunction · 0.85

Tested by

no test coverage detected