Shortcuts

torchaudio.functional.frechet_distance

torchaudio.functional.frechet_distance(mu_x, sigma_x, mu_y, sigma_y)[source]

Computes the Fréchet distance between two multivariate normal distributions [Dowson and Landau, 1982].

Concretely, for multivariate Gaussians \(X(\mu_X, \Sigma_X)\) and \(Y(\mu_Y, \Sigma_Y)\), the function computes and returns \(F\) as

\[F(X, Y) = || \mu_X - \mu_Y ||_2^2 + \text{Tr}\left( \Sigma_X + \Sigma_Y - 2 \sqrt{\Sigma_X \Sigma_Y} \right) \]
Parameters:
  • mu_x (torch.Tensor) – mean \(\mu_X\) of multivariate Gaussian \(X\), with shape (N,).

  • sigma_x (torch.Tensor) – covariance matrix \(\Sigma_X\) of \(X\), with shape (N, N).

  • mu_y (torch.Tensor) – mean \(\mu_Y\) of multivariate Gaussian \(Y\), with shape (N,).

  • sigma_y (torch.Tensor) – covariance matrix \(\Sigma_Y\) of \(Y\), with shape (N, N).

Returns:

the Fréchet distance between \(X\) and \(Y\).

Return type:

torch.Tensor

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources