MCPcopy Create free account
hub / github.com/tinygrad/tinygrad / compute_score

Method compute_score

extra/models/inception.py:312–321  ·  view source on GitHub ↗
(self, inception_activations:Tensor, val_stats_path:str)

Source from the content-addressed store, hash-verified

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
323def 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)

Callers 1

eval_unetFunction · 0.80

Calls 4

meanMethod · 0.80
loadMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected