(self, input_dim, max_freq_log2, N_freqs,
log_sampling=True, include_input=True,
periodic_fns=(torch.sin, torch.cos))
| 4 | |
| 5 | class FreqEncoder(nn.Module): |
| 6 | def __init__(self, input_dim, max_freq_log2, N_freqs, |
| 7 | log_sampling=True, include_input=True, |
| 8 | periodic_fns=(torch.sin, torch.cos)): |
| 9 | |
| 10 | super().__init__() |
| 11 | |
| 12 | self.input_dim = input_dim |
| 13 | self.include_input = include_input |
| 14 | self.periodic_fns = periodic_fns |
| 15 | |
| 16 | self.output_dim = 0 |
| 17 | if self.include_input: |
| 18 | self.output_dim += self.input_dim |
| 19 | |
| 20 | self.output_dim += self.input_dim * N_freqs * len(self.periodic_fns) |
| 21 | |
| 22 | if log_sampling: |
| 23 | self.freq_bands = 2. ** torch.linspace(0., max_freq_log2, N_freqs) |
| 24 | else: |
| 25 | self.freq_bands = torch.linspace(2. ** 0., 2. ** max_freq_log2, N_freqs) |
| 26 | |
| 27 | self.freq_bands = self.freq_bands.numpy().tolist() |
| 28 | |
| 29 | def forward(self, input, **kwargs): |
| 30 |
nothing calls this directly
no outgoing calls
no test coverage detected