MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / aggregate

Method aggregate

mmseg/ops/encoding.py:42–49  ·  view source on GitHub ↗
(assignment_weights, x, codewords)

Source from the content-addressed store, hash-verified

40
41 @staticmethod
42 def aggregate(assignment_weights, x, codewords):
43 num_codes, channels = codewords.size()
44 reshaped_codewords = codewords.view((1, 1, num_codes, channels))
45 batch_size = x.size(0)
46
47 expanded_x = x.unsqueeze(2).expand((batch_size, x.size(1), num_codes, channels))
48 encoded_feat = (assignment_weights.unsqueeze(3) * (expanded_x - reshaped_codewords)).sum(dim=1)
49 return encoded_feat
50
51 def forward(self, x):
52 assert x.dim() == 4 and x.size(1) == self.channels

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected