InceptionScore<T>

Models & Types · AiDotNet.Metrics

Inception Score (IS) - A metric for evaluating the quality and diversity of generated images.

For Beginners: Inception Score measures two important properties of generated images:

  1. Quality: Each image should clearly belong to one class (low entropy)
  2. Diversity: The collection should cover many different classes (high entropy)

Think of it like evaluating an art student’s portfolio:

  • Quality: Each drawing should be clearly recognizable (is it a cat? a dog? a car?)
  • Diversity: The portfolio should have many different subjects, not just cats

How it works:

  1. Pass generated images through a pre-trained Inception classifier
  2. Get probability distributions over classes (e.g., “70% cat, 20% dog, 10% other”)
  3. For quality: Check if predictions are confident (peaked distributions)
  4. For diversity: Check if many different classes are represented
  5. Combine using KL divergence: IS = exp(E[KL(p(y|x) || p(y))])

The math behind it:

  • p(y|x): Probability of class y given image x (conditional distribution)
  • p(y): Overall probability of class y across all images (marginal distribution)
  • KL divergence measures how different these two distributions are
  • Higher KL = more confident predictions + diverse outputs = Better IS

Typical Inception Scores:

  • IS > 10: Excellent (ImageNet-quality)
  • IS 5-10: Good quality
  • IS 2-5: Moderate quality
  • IS < 2: Poor quality (random noise ≈ 1)

Important notes:

  • IS can be “fooled” by mode collapse (generating same high-quality image repeatedly)
  • FID is generally considered more reliable, but IS is still widely used
  • Scores only meaningful within same dataset (can’t compare IS on different datasets)

Based on “Improved Techniques for Training GANs” by Salimans et al. (2016)

Constructors

Constructor Summary
InceptionScore(ConvolutionalNeuralNetwork<T> inceptionNetwork, int numClasses, int numSplits) Initializes a new instance of Inception Score calculator.

Properties

Property Summary
ConvolutionalNeuralNetwork<T> InceptionNetwork { get; set; } Gets the Inception network used for classification.
int NumClasses { get; set; } Gets the number of classes in the classifier.
int NumSplits { get; set; } Gets or sets the number of splits for computing IS with uncertainty.

Methods

Method Summary
T ComputeIS(Tensor<T> generatedImages) Computes the Inception Score for a set of generated images.
ValueTuple<T, T, T, bool> ComputeComprehensiveMetrics(Tensor<T> generatedImages, Tensor<T> realImages) Computes both IS and FID if a FID calculator is provided.
ValueTuple<T, T> ComputeISWithUncertainty(Tensor<T> generatedImages) Computes Inception Score with mean and standard deviation across splits.