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