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(μX,ΣX)X(\mu_X, \Sigma_X) and Y(μY,ΣY)Y(\mu_Y, \Sigma_Y), the function computes and returns FF as

F(X,Y)=μXμY22+Tr(ΣX+ΣY2ΣXΣY)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 μX\mu_X of multivariate Gaussian XX, with shape (N,).

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

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

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

Returns:

the Fréchet distance between XX and YY.

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