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

Method __init__

mmseg/ops/encoding.py:18–28  ·  view source on GitHub ↗
(self, channels, num_codes)

Source from the content-addressed store, hash-verified

16 """
17
18 def __init__(self, channels, num_codes):
19 super(Encoding, self).__init__()
20 # init codewords and smoothing factor
21 self.channels, self.num_codes = channels, num_codes
22 std = 1.0 / ((num_codes * channels) ** 0.5)
23 # [num_codes, channels]
24 self.codewords = nn.Parameter(
25 torch.empty(num_codes, channels, dtype=torch.float).uniform_(-std, std), requires_grad=True
26 )
27 # [num_codes]
28 self.scale = nn.Parameter(torch.empty(num_codes, dtype=torch.float).uniform_(-1, 0), requires_grad=True)
29
30 @staticmethod
31 def scaled_l2(x, codewords, scale):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected