(self, x: torch.Tensor, emb: torch.Tensor)
| 263 | self.linear = nn.Linear(embedding_dim, out_dim * 2) |
| 264 | |
| 265 | def forward(self, x: torch.Tensor, emb: torch.Tensor) -> torch.Tensor: |
| 266 | if self.act: |
| 267 | emb = self.act(emb) |
| 268 | emb = self.linear(emb) |
| 269 | emb = emb[:, :, None, None] |
| 270 | scale, shift = emb.chunk(2, dim=1) |
| 271 | |
| 272 | x = F.group_norm(x, self.num_groups, eps=self.eps) |
| 273 | x = x * (1 + scale) + shift |
| 274 | return x |
| 275 | |
| 276 | |
| 277 | class AdaLayerNormContinuous(nn.Module): |