synthval.metrics.KernelDistance#

class synthval.metrics.KernelDistance(max_samples=1000000, num_subsets=100, max_subset_size=1000)#

Bases: SimilarityMetric

Similarity Metric that computes the Kernel distance between two distributions using provided samples.

If the features extracted are from the last average pooling layer of the Inception model (e.g., from synthval.features_extraction.InceptionExtractor), this metric corresponds to the standard Kernel Inception Distance (KID).

Parameters:
  • max_samples (int)

  • num_subsets (int)

  • max_subset_size (int)

max_samples#

Max number of samples to consider in the computation. To use in the case of limited time or hardware capabilities (default: 1000000).

Type:

int, Optional

num_subsets#

Number of subset to use for calculating the Kernel distance (default: 100).

Type:

int, Optional

max_subset_size#

Maximum size of each subset (default: 1000).

Type:

int, Optional

References

Mikolaj Binkowski, Danica J. Sutherland, Michael Arbel, Arthur Gretton - Demystifying MMD GANs - 6th International Conference on Learning Representations, 2018.

calculate(real_dist_df, synth_dist_df)#

Compute the Kernel distance between two distributions using the samples provided.

Parameters:
  • real_dist_df (pandas.DataFrame) – Set of samples representing distribution real_dist.

  • synth_dist_df (pandas.DataFrame) – Set of samples representing distribution synth_dist.

Returns:

A numpy array containing the Kernel Distance.

Return type:

numpy.ndarray