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