(self, channels, num_codes)
| 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): |
nothing calls this directly
no outgoing calls
no test coverage detected