(self, in_channels, out_channels, seq_len, modes=0, mode_select_method='random')
| 49 | # ########## fourier layer ############# |
| 50 | class 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): |
no test coverage detected