| 64 | self.latent_std = nn.Parameter(torch.ones([self.embedding_dim * latent_temporal_chunk], dtype=torch.float32)) |
| 65 | |
| 66 | def encode(self, x): |
| 67 | h = self.encoder(x) |
| 68 | z = self.quant_conv(h) |
| 69 | latent_ch = z.shape[1] |
| 70 | latent_t = z.shape[2] |
| 71 | dtype = z.dtype |
| 72 | mean = self.latent_mean.view(latent_ch, -1)[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=dtype, device=z.device) |
| 73 | std = self.latent_std.view(latent_ch, -1)[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=dtype, device=z.device) |
| 74 | return ((z - mean) / std) * self.sigma_data |
| 75 | |
| 76 | def decode(self, z): |
| 77 | in_dtype = z.dtype |