(self, t, channels)
| 215 | self.label_emb = nn.Embedding(num_classes, time_dim) |
| 216 | |
| 217 | def pos_encoding(self, t, channels): |
| 218 | inv_freq = 1.0 / ( |
| 219 | 10000 |
| 220 | ** (torch.arange(0, channels, 2, device=self.device).float() / channels) |
| 221 | ) |
| 222 | pos_enc_a = torch.sin(t.repeat(1, channels // 2) * inv_freq) |
| 223 | pos_enc_b = torch.cos(t.repeat(1, channels // 2) * inv_freq) |
| 224 | pos_enc = torch.cat([pos_enc_a, pos_enc_b], dim=-1) |
| 225 | return pos_enc |
| 226 | |
| 227 | def forward(self, x, t, y): |
| 228 | t = t.unsqueeze(-1).type(torch.float) |