| 59 | |
| 60 | |
| 61 | class FFN(nn.Module): |
| 62 | |
| 63 | def __init__(self, latent_dim, ffn_dim, dropout, time_embed_dim): |
| 64 | super().__init__() |
| 65 | self.linear1 = nn.Linear(latent_dim, ffn_dim) |
| 66 | self.linear2 = zero_module(nn.Linear(ffn_dim, latent_dim)) |
| 67 | self.activation = nn.GELU() |
| 68 | self.dropout = nn.Dropout(dropout) |
| 69 | self.proj_out = StylizationBlock(latent_dim, time_embed_dim, dropout) |
| 70 | |
| 71 | def forward(self, x, emb, **kwargs): |
| 72 | y = self.linear2(self.dropout(self.activation(self.linear1(x)))) |
| 73 | y = x + self.proj_out(y, emb) |
| 74 | return y |
| 75 | |
| 76 | |
| 77 | class DecoderLayer(nn.Module): |