MCPcopy Create free account
hub / github.com/devinxzhang/MFuser / __init__

Method __init__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected