Week-10 · ML-2026
Compress, map, group — and learn a latent model
Alexei Kornaev,
Dr. Sc., Prof.
Innopolis University
Researcher at the RC for AI,
National RC for Oncology n.a. N.N. Blokhin
Educational draft · Instructor review pending

| Purpose | Evidence |
|---|---|
| Compress | Reconstruction on new observations |
| Map | Neighbor identities preserved |
| Group | Metric, stability, usefulness |
| Generate | Sampling law and model diagnostics |
Choose the question before judging the result.
Filled blue circles: observations; open green circles: projections; dashed orange segments: lost residuals. Point numbers identify the same observations in both views. Move the angle with the slider or arrow keys; the data stay fixed.
Move the slider to rotate the projection line.
Filled circles mark observations. Open circles mark projections. Dashed lines show residuals.
At 45°: retained 32, lost 8.
Follow the same numbered observations through the panels.
Changing basis is reversible; dropping coordinates loses information.
For and :
Maximum retained variance gives minimum squared projection error.
Each row of is one centered observation. Diagonal entries are feature variances. Off-diagonal entries measure how two features vary together.
Matching signs contribute positively; opposite signs negatively.
Changing metres to centimetres multiplies that feature’s variance by 10,000.
Feature scales define what counts as large variation.
is the vector of partial derivatives with respect to the components of .
The largest eigenvalue gives the most retained variance.
Input: training rows and retained dimension .
New observation: with saved statistics.
Input: scores and the same saved mean and basis.
Restoring the feature count does not restore discarded information.
1 · Observations .
2 · Center Track point 1: .
3 · Covariance
4 · Principal directions
5 · Retain and encode Point 1: .
6 · Expand and restore Point 1: .
: retain 80% of variation; per-feature MSE .
measurements; a score weights one shared pattern.
A component need not be a named visual concept.
Same held-out images; one nested basis.
More retained directions remove squared residual components.
Predict the retained direction for the two horizontal strips.
High variance and useful class information can point in different directions.
Stochastic neighbor embedding (SNE) places each observation at a point on a map.
For input point , turn distances to the other points into weights. Normalize across candidates :
is the probability of choosing as a neighbor of .
Small concentrates probability on close neighbors.
A larger spreads probability over more points.
Perplexity is the effective number of neighbors. Choose a target and adjust separately for each point.
Give each observation a map position . Use Gaussian weights with a fixed scale on the map:
Move all to minimize the sum of neighborhood mismatches:
If is large, a tiny is costly.
Symmetric pairs: combine both input neighbor directions.
Student kernel: use on the map. Its slower decay helps ease crowding.
Read the map through local neighbors. Island gaps depend on the fit.
There are points. Each squared distance sums over the feature coordinates.
Assign: points change groups while centers stay fixed.
Update: centers move to group means while memberships stay fixed.
Nearest-center regions favor compact groups.
Compactness, stability and usefulness need separate checks.
With , the fit recovers both generating groups in this sample.

The dataset labels this image Pneumonia.
K = 2, 3, 4: each fit divides brightness into more bands. Panel titles give fitted centers from darkest to brightest.
Dark blue marks the lowest band. Pale yellow marks the highest. Bright hardware and tissue can share a band.
Data provider: NIH Clinical Center · NIH ChestX-ray14 download · Wang et al., CVPR 2017

The encoder maps an image to code . The decoder reconstructs the input. Reconstruction error updates both networks.
| Stage | Operation |
|---|---|
| Specify | Encoder, decoder, bottleneck and loss |
| Forward | ; |
| Score | |
| Update | Clear gradients; backpropagate; update both networks |
| Check | Measure held-out reconstruction with fixed weights |
| Use | Encode/reconstruct a new image with fixed weights |
A constraint makes copying harder and forces information selection.
A small code still does not guarantee meaningful features.
Same held-out images; bottlenecks of 2 and 16.
Measure recovery separately from recognition.
Freeze encoder → encode → train labeled probe → validate choices → test once.
Ask where labels enter this experiment.
Downstream usefulness needs a declared task.
The encoder gives each image a distribution of possible codes.
A sampled code enters the decoder; the same input supplies the reconstruction target.
No digit label or correct code is provided.
| Distribution | Question |
|---|---|
| Codes before observing this image? | |
| Which codes explain it under the model? | |
| What can the encoder approximate? |
These describe image codes, rather than network-weight uncertainty.

The diagram uses for the encoder weights we call .
Reconstruction cost: retain information that helps explain this image.
Prior KL cost: compare this image’s approximate posterior with the shared prior.
We will derive why these terms belong together.
Each batch output has shape : scalars per image.
Evaluating the distribution at an image gives one scalar density.
Latent and pixel spread have different roles.
We would like to increase .
The nonlinear decoder makes this integral difficult.
The encoder proposes image-specific codes for a computable bound.
Fix ; expectations are over .
The posterior comparison is a derivation tool.
For fixed , abbreviate .
The first expectation is the prior KL.
Thus .
The prior KL belongs in the bound; posterior KL measures its gap.
Both networks learn through one objective.
For one fixed image and sampled code:
Conditional pixel independence gives a product over pixels.
Negative logarithms turn that product into a sum.
For the fixed Gaussian observation model:
Pixel-density product → log-density sum.
For each image, estimate the average over encoder codes with one draw during training.
The observation model determines the reconstruction term.
Schematic image: ; , .
, , .
Suppose ; .
| Pixel | Observed | Mean | Scaled squared residual |
|---|---|---|---|
| 1 | .7 | .8 | .08 |
| 2 | .4 | .2 | .32 |
| 3 | .1 | .2 | .08 |
| 4 | .9 | .8 | .08 |
, where .
The encoder gives a diagonal Gaussian with means and standard deviations . The prior is standard normal.
Compute this directly from the encoder outputs. It penalizes means away from zero and variances away from one.
Reconstruction alone: no explicit prior cost for distant, extremely narrow image-specific code distributions.
KL alone: every image could receive the same standard normal and pay zero.
Together, the terms balance image information and prior cost.
, .
Sum pixel and latent contributions within each image.
For image , draw from .
Sum over pixels in and over latent coordinates in . Then average over images.
PCA: saved linear coordinates. t-SNE: inspect neighbors.
K-means: compact groups.
AE: nonlinear reconstruction. VAE: latent probabilistic learning.
Next: construct training relationships for useful representations.
2006: learned low-dimensional reconstruction — Hinton & Salakhutdinov.
2008: local-affinity maps — van der Maaten & Hinton.
2013/2014: joint latent generation and inference — Kingma & Welling.
History connects methods to the problems they addressed.

Diederik P. (Durk) Kingma
Variational autoencoders with Max Welling.

Geoffrey Hinton
Autoencoders with Ruslan Salakhutdinov; t-SNE with van der Maaten.
Portraits reused from Weeks 07/04. AEVB · Autoencoders (2006) · t-SNE (2008).

Draw a code from the prior. The trained decoder gives observation parameters. A chosen path between codes illustrates interpolation.
| Operation | Algorithm | Label |
|---|---|---|
| Reconstruct | Encode an image; use mean or draw; decode | Mean-code or posterior-draw reconstruction |
| Generate | Draw prior code; decode; optionally draw observation | Decoder mean or observation draw |
| Interpolate | Choose two codes and | Chosen path, usually decoded means |
Fixed trained MNIST model · fresh prior codes · .
A uniform coordinate grid is not probability-weighted prior sampling.
Endpoints are reconstructions; intermediate outputs are not random samples.
← Lectures Introduction to Machine Learning · Week 10