| 260 | |
| 261 | class sparseKernelFT1d(nn.Module): |
| 262 | def __init__(self, |
| 263 | k, alpha, c=1, |
| 264 | nl=1, |
| 265 | initializer=None, |
| 266 | **kwargs): |
| 267 | super(sparseKernelFT1d, self).__init__() |
| 268 | |
| 269 | self.modes1 = alpha |
| 270 | self.scale = (1 / (c * k * c * k)) |
| 271 | self.weights1 = nn.Parameter(self.scale * torch.rand(c * k, c * k, self.modes1, dtype=torch.cfloat)) |
| 272 | self.weights1.requires_grad = True |
| 273 | self.k = k |
| 274 | |
| 275 | def compl_mul1d(self, x, weights): |
| 276 | # (batch, in_channel, x ), (in_channel, out_channel, x) -> (batch, out_channel, x) |