(shape, device, repeat=False)
| 77 | |
| 78 | |
| 79 | def noise_like(shape, device, repeat=False): |
| 80 | def repeat_noise(): |
| 81 | return torch.randn((1, *shape[1:]), device=device).repeat( |
| 82 | shape[0], *((1,) * (len(shape) - 1)) |
| 83 | ) |
| 84 | |
| 85 | def noise(): |
| 86 | return torch.randn(shape, device=device) |
| 87 | |
| 88 | return repeat_noise() if repeat else noise() |
| 89 | |
| 90 | |
| 91 | def normal_kl(mean1, logvar1, mean2, logvar2): |
no test coverage detected