Presets
Playback
Classes
Episode
Prototype and softmax
Camera
Layers
Quality
Model check
The science
Few-shot episodes
In N-way K-shot learning a model sees a support set of K labelled examples for each of N new classes and must label unseen query examples from those classes. Each episode here draws N class centres in a 2-D embedding plane and then Gaussian clouds of radius sigma around them: K support points and several query points per class.
The prototypical-network rule
The prototype of class k is the mean of its support embeddings: c_k = (1/K) sum_i f(x_i). A query x is classified by a softmax over negative squared distances: p(y=k|x) = exp(-s d(x,c_k)^2) / sum_j exp(-s d(x,c_j)^2), d = Euclidean distance. The most probable class is always the nearest prototype, and the loss is the cross-entropy -ln p(true class). The sharpness s changes confidence and loss but never the accuracy.
Why the mean?
The mean minimises the summed squared distance to the support points (check 3). For clean data with K shots its error obeys E|c_hat - mu|^2 = 2 sigma^2 / K in two dimensions (check 1), so more shots shrink the prototype error as 1/K.
Bayes limit
For equal-prior isotropic Gaussians the best possible rule is the nearest true centre. The Monte-Carlo curves compare the prototype rule with it; the prototype rule can never beat it, and the gap closes as K grows (check 4).
Honest simplifications
Real prototypical networks learn the embedding f with a neural network over many training episodes; here the embedding plane is given directly as 2-D Gaussians, so only the few-shot classification step is simulated. Class clouds are isotropic with equal spread, which makes the Euclidean rule near optimal. Mislabelled support points and the median prototype are added to show how sensitive the mean is to outliers.
Model checks
(1) prototype error against 2 sigma^2/K, (2) softmax normalisation and argmax = nearest prototype, (3) the mean minimises the support cost, (4) accuracy never above the Bayes limit and the gap shrinks with shots. All are recomputed by Monte Carlo every few seconds.
What you see in 3D
Each tall obelisk is a class prototype at the mean of its support gems. Floor columns are coloured by the nearest prototype and rise with the softmax confidence max_k p(k|x); the ridges between classes are where the model is unsure. Beads are query examples, rings mark errors. The numbers come from the same engine as the 2D page.