Open francois-rozet opened 1 year ago
Hello, I think the following implementation of the Fréchet distance is faster than the current one and would allow to drop the scipy dependency.
scipy
def frechet_distance(mu_x: Tensor, sigma_x: Tensor, mu_y: Tensor, sigma_y: Tensor) -> Tensor: a = (mu_x - mu_y).square().sum(dim=-1) b = sigma_x.trace() + sigma_y.trace() c = torch.linalg.eigvals(sigma_x @ sigma_y).sqrt().real.sum(dim=-1) return a + b - 2 * c
The implementation is based on two facts:
Hello, I think the following implementation of the Fréchet distance is faster than the current one and would allow to drop the
scipy
dependency.The implementation is based on two facts: