(self, t, channels)
| 151 | self.outc = nn.Conv2d(64, c_out, kernel_size=1) |
| 152 | |
| 153 | def pos_encoding(self, t, channels): |
| 154 | inv_freq = 1.0 / ( |
| 155 | 10000 |
| 156 | ** (torch.arange(0, channels, 2, device=self.device).float() / channels) |
| 157 | ) |
| 158 | pos_enc_a = torch.sin(t.repeat(1, channels // 2) * inv_freq) |
| 159 | pos_enc_b = torch.cos(t.repeat(1, channels // 2) * inv_freq) |
| 160 | pos_enc = torch.cat([pos_enc_a, pos_enc_b], dim=-1) |
| 161 | return pos_enc |
| 162 | |
| 163 | def forward(self, x, t): |
| 164 | t = t.unsqueeze(-1).type(torch.float) |