(self, inception_activations:Tensor, val_stats_path:str)
| 310 | return x |
| 311 | |
| 312 | def compute_score(self, inception_activations:Tensor, val_stats_path:str) -> float: |
| 313 | if self.m1 is None and self.s1 is None: |
| 314 | with np.load(val_stats_path) as f: |
| 315 | self.m1, self.s1 = f['mu'][:], f['sigma'][:] |
| 316 | assert self.m1 is not None and self.s1 is not None |
| 317 | |
| 318 | m2 = inception_activations.mean(axis=0).numpy() |
| 319 | s2 = np.cov(inception_activations.numpy(), rowvar=False) |
| 320 | |
| 321 | return calculate_frechet_distance(self.m1, self.s1, m2, s2) |
| 322 | |
| 323 | def calculate_frechet_distance(mu1:np.ndarray, sigma1:np.ndarray, mu2:np.ndarray, sigma2:np.ndarray, eps:float=1e-6) -> float: |
| 324 | mu1 = np.atleast_1d(mu1) |
no test coverage detected