MCPcopy Create free account
hub / github.com/BorealisAI/scaleformer / __init__

Method __init__

layers/FourierCorrelation.py:51–64  ·  view source on GitHub ↗
(self, in_channels, out_channels, seq_len, modes=0, mode_select_method='random')

Source from the content-addressed store, hash-verified

49# ########## fourier layer #############
50class FourierBlock(nn.Module):
51 def __init__(self, in_channels, out_channels, seq_len, modes=0, mode_select_method='random'):
52 super(FourierBlock, self).__init__()
53 print('fourier enhanced block used!')
54 """
55 1D Fourier block. It performs representation learning on frequency domain,
56 it does FFT, linear transform, and Inverse FFT.
57 """
58 # get modes on frequency domain
59 self.index = get_frequency_modes(seq_len, modes=modes, mode_select_method=mode_select_method)
60 print('modes={}, index={}'.format(modes, self.index))
61
62 self.scale = (1 / (in_channels * out_channels))
63 self.weights1 = nn.Parameter(
64 self.scale * torch.rand(8, in_channels // 8, out_channels // 8, len(self.index), dtype=torch.cfloat))
65
66 # Complex multiplication
67 def compl_mul1d(self, input, weights):

Callers 1

__init__Method · 0.45

Calls 1

get_frequency_modesFunction · 0.85

Tested by

no test coverage detected