(self, input_dim, hidden_dims, sigma_dim, embed_type="sinusoidal",
operation="post_add")
| 13 | @R.register("layers.SigmaEmbeddingLayer") |
| 14 | class SigmaEmbeddingLayer(nn.Module, core.Configurable): |
| 15 | def __init__(self, input_dim, hidden_dims, sigma_dim, embed_type="sinusoidal", |
| 16 | operation="post_add"): |
| 17 | super(SigmaEmbeddingLayer, self).__init__() |
| 18 | self.input_dim = input_dim |
| 19 | self.hidden_dims = hidden_dims |
| 20 | self.output_dim = hidden_dims[-1] |
| 21 | self.sigma_dim = sigma_dim |
| 22 | self.embed_func = get_timestep_embedding(embed_type, sigma_dim) |
| 23 | self.operation = operation |
| 24 | if self.operation == "post_add": |
| 25 | self.sigma_linear = nn.Linear(sigma_dim, hidden_dims[-1]) |
| 26 | self.mlp = layers.MLP(input_dim, hidden_dims, short_cut=True) |
| 27 | elif self.operation == "pre_concat": |
| 28 | self.mlp = layers.MLP(input_dim + sigma_dim, hidden_dims, short_cut=True) |
| 29 | |
| 30 | def forward(self, input, sigma): |
| 31 | sigma_embed = self.embed_func(sigma) |
no test coverage detected