* `n_channels` is the number of dimensions in the embedding
(self, n_channels: int)
| 22 | """ |
| 23 | |
| 24 | def __init__(self, n_channels: int): |
| 25 | """ |
| 26 | * `n_channels` is the number of dimensions in the embedding |
| 27 | """ |
| 28 | super().__init__() |
| 29 | self.n_channels = n_channels |
| 30 | # First linear layer |
| 31 | self.lin1 = nn.Linear(self.n_channels // 4, self.n_channels) |
| 32 | # Activation |
| 33 | self.act = Swish() |
| 34 | # Second linear layer |
| 35 | self.lin2 = nn.Linear(self.n_channels, self.n_channels) |
| 36 | |
| 37 | def forward(self, t: torch.Tensor): |
| 38 | # Create sinusoidal position embeddings |