Args: x: torch.Tensor, shape (b, 3, h, w) in [-1, 1]
(self, x)
| 64 | |
| 65 | @torch.no_grad() |
| 66 | def encode(self, x): |
| 67 | """ |
| 68 | Args: |
| 69 | x: torch.Tensor, shape (b, 3, h, w) in [-1, 1] |
| 70 | """ |
| 71 | # scale to [0, 1] |
| 72 | x = x.div(2).add(0.5) |
| 73 | return self.encoder(x) |
| 74 | |
| 75 | @torch.no_grad() |
| 76 | def decode(self, z): |