MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / MPFourier

Class MPFourier

modules/edm2_modules.py:5–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4
5class MPFourier(torch.nn.Module):
6 def __init__(self, num_channels, bandwidth=1):
7 super().__init__()
8 self.register_buffer('freqs', 2 * np.pi * torch.randn(num_channels) * bandwidth)
9 self.register_buffer('phases', 2 * np.pi * torch.rand(num_channels))
10
11 def forward(self, x):
12 y = x.to(torch.float32)
13 y = y.ger(self.freqs.to(torch.float32))
14 y = y + self.phases.to(torch.float32)
15 y = y.cos() * np.sqrt(2)
16 return y.to(x.dtype)

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected