MCPcopy Create free account
hub / github.com/NVlabs/SegFormer / __init__

Method __init__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected