Disentangled representations
解耦表示
Separate semantic factors, coordinate alignment and group actions with a brightness–orientation model.
disentanglementStart with the problem
Imagine two controls on an image generator: one changes brightness, the other turns an object. A representation is easier to use if those changes can be handled separately. Disentanglement asks what “separately” should mean, how to learn it and how to test it.
It need not mean one semantic factor per scalar neuron. An angle wraps around: zero and a full turn describe the same orientation. A two-coordinate cosine/sine block can represent that factor continuously. Nor does reconstructing every image prove that the chosen coordinates line up with the controls.
Higgins and colleagues define disentangled group actions relative to a decomposition of transformations. Their definition explicitly allows the factor subspaces to be unaligned with the currently displayed coordinate axes. That qualification matters: invertibly mixing a code can obscure an axis-based diagnostic while preserving disentanglement in transformed subspaces. Towards a Definition of Disentangled Representations — arXiv v1
Our example makes that distinction numerical. It uses a known four-pixel renderer, compares coordinate sensitivities before and after mixing, and then uses labeled calibration examples to recover the original coordinates.
Definitions and derivation
Let b be log brightness and theta an angle. Brightness is positive because its value is exp(b). Define a three-entry code and a four-pixel observation:
The mean pixel value is exp(b). Taking its logarithm recovers b; subtracting opposite pixels and dividing by the mean recovers cosine and sine. This inverse is supplied by the known renderer. It is not learned from unlabeled images.
Changing b translates the first code coordinate; changing theta rotates the last two. These actions commute and affect separate blocks. Their correspondence between world and code is equivariance. For an invertible row-vector mixing matrix R, the mixed code is , with transported actions:
The original factor spaces move with R. They need not coincide with the first coordinate and last-two-coordinate blocks anymore. Therefore the mixed representation can still satisfy Higgins’s broader group-action definition. Our brightness action in log coordinates is affine, so we are not claiming a wholly linear group representation. Towards a Definition of Disentangled Representations — arXiv v1
To measure alignment with the declared coordinate blocks, form the Jacobian with columns for brightness and angle. Penalize brightness derivatives in the last two rows and angle derivative in the first:
S is an explicitly basis-dependent derivative diagnostic, not a universal disentanglement score. For our fixed matrix at theta 0.6, it changes from zero to about 0.133695408. Reconstruction remains exact because R is invertible. The two facts are compatible.
Run the calculation
Run CPython 3.12.4 with NumPy 1.26.4. The first comparison uses brightness 1.5 and angle 0.6 radians. It prints both codes, both intervention Jacobians and the declared wrong-block derivative energy. Four known factor/code pairs then fit an unmixing map by least squares. Held-out brightness/angle combinations recover the target code to about 1.39e−15. This final step is supervised calibration with a full-rank design, not unsupervised discovery of physical factors.
import numpy as np
MIX=np.array([[1.,.3,.2],[.4,1,.1],[.2,.5,1.]])
def render(code):
code=np.asarray(code,dtype=float);brightness=np.exp(code[...,0]);cosine=code[...,1];sine=code[...,2];return brightness[...,None]*np.stack([1+.5*cosine,1+.5*sine,1-.5*cosine,1-.5*sine],axis=-1)
def encode(image):
image=np.asarray(image,dtype=float);brightness=image.mean(axis=-1)
if image.shape[-1]!=4 or np.any(brightness<=0) or not np.isfinite(image).all():raise ValueError('Use finite four-pixel observations with positive mean brightness.')
return np.stack([np.log(brightness),(image[...,0]-image[...,2])/brightness,(image[...,1]-image[...,3])/brightness],axis=-1)
def code(log_brightness,angle):return np.array([log_brightness,np.cos(angle),np.sin(angle)])
def jacobian(angle):return np.array([[1.,0],[0,-np.sin(angle)],[0,np.cos(angle)]])
def calibration():
targets=np.array([code(0.,0.),code(0.,np.pi/2),code(np.log(2),np.pi),code(-np.log(2),3*np.pi/2)]);mixed=targets@MIX;unmix=np.linalg.lstsq(mixed,targets,rcond=None)[0];return unmix
if __name__=='__main__':
c=code(np.log(1.5),.6);image=render(c);ideal=encode(image);mixed=ideal@MIX;reconstruction=render(mixed@np.linalg.inv(MIX));print('ideal / mixed code',ideal.round(9).tolist(),mixed.round(9).tolist(),'reconstruction error',float(np.max(np.abs(reconstruction-image))))
ji=jacobian(.6);jm=MIX.T@ji;print('ideal intervention Jacobian',ji.round(6).tolist(),'mixed Jacobian',jm.round(6).tolist());print('wrong-block derivative energy',round(float(np.sum(ji[1:,0]**2)+ji[0,1]**2),9),round(float(np.sum(jm[1:,0]**2)+jm[0,1]**2),9))
unmix=calibration();test=np.array([code(b,a) for b in (-.3,.4) for a in np.linspace(0,2*np.pi,7)]);print('supervised unmix held-out error',float(np.max(np.abs((test@MIX)@unmix-test))))
ideal / mixed code [0.405465108, 0.825335615, 0.564642473] [0.848527849, 1.229296384, 0.728269057] reconstruction error 0.0
ideal intervention Jacobian [[1.0, 0.0], [0.0, -0.564642], [0.0, 0.825336]] mixed Jacobian [[1.0, -0.06079], [0.3, -0.151975], [0.2, 0.768871]]
wrong-block derivative energy 0.0 0.133695408
supervised unmix held-out error 1.3877787807814457e-15
When the method fails
A score is meaningful only with its assumptions attached. Our S depends on factor units, coordinate units and the selected blocks. Rescaling brightness or rotating the coordinate system can change it. It tests local derivatives at one state; it does not certify behavior throughout a dataset. The broad group-action definition and this coordinate-alignment diagnostic answer different questions.
Locatello and colleagues show non-identifiability for a specified unsupervised latent-variable setting: alternative latent descriptions can preserve the observation distribution while mixing factors. Their result motivates the need for inductive biases or supervision; it does not say that every unsupervised method or every restricted model is impossible. Here the renderer and calibration labels supply exactly such extra information. Challenging Common Assumptions in the Unsupervised Learning of Disentangled Representations
Real observations may hide factors through occlusion, measurement noise or many-to-one rendering. Brightness and orientation may not vary independently in the data, and some transformation families do not decompose into commuting independent controls. Do not infer causal controllability merely from a sparse Jacobian or a high benchmark score. State the factor definition, observations and interventions available to the learner.
Exercises with answers
- Why represent one orientation factor with two coordinates?
Answer 1: Cosine and sine vary continuously through a full turn and identify angles modulo 2π; a single wrapped angle has a coordinate discontinuity.
- Does invertible mixing necessarily destroy group-based disentanglement?
Answer 2: No. The factor subspaces and actions can be transported through the mixing, although their alignment with the displayed axes changes.
- What extra information does calibration use?
Answer 3: Known target factor codes for four examples, so the least-squares unmixing is supervised.
- Does exact reconstruction prove the first coordinate controls only brightness?
Answer 4: No. Both mixed and original codes reconstruct exactly; inspect the declared-coordinate Jacobian or specified group actions separately.
Sources and next steps
Read Higgins Sections 5.1–5.2 especially the sentence allowing subspaces that do not align with a given basis. Read Locatello’s Theorem 1 together with its latent-distribution assumptions. Continue with equivariant networks for transformation-aware architectures and unsupervised learning for identifiability. Extending this experiment with noise should report reconstruction error, supervised calibration error and basis-dependent alignment separately. Towards a Definition of Disentangled Representations — arXiv v1; Challenging Common Assumptions in the Unsupervised Learning of Disentangled Representations
Make a prediction, then check
An invertible mixing worsens a coordinate-block score. What follows?
Learning objectives
- Distinguish a coordinate-block diagnostic from a group-based definition.
- Explain what renderer knowledge and calibration labels add to identifiability.
Prerequisites & connections
Explore related knowledge →References
- Towards a Definition of Disentangled Representations — arXiv v1
Irina Higgins; David Amos; David Pfau; Sebastien Racaniere; Loic Matthey; Danilo Rezende; Alexander Lerchner · 2018 - Challenging Common Assumptions in the Unsupervised Learning of Disentangled Representations
Francesco Locatello; Stefan Bauer; Mario Lucic; Gunnar Rätsch; Sylvain Gelly; Bernhard Schölkopf; Olivier Bachem · 2019
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-07 · Codex single-AI-author technical check: primary-source scope, explicit assumptions, original calculations, independent mathematical references and bilingual tests; not independent human or second-agent review.
- Single-AI-author technical check: bounded primary-source reading, explicit assumptions, original calculations, runnable examples and matching bilingual equations, code and exercises. Not an independent human or second-agent review.
- Four focused CPython 3.12.4 tests passed per chapter: finite-difference gradients, sample covariance, teacher/center update order, hidden-input isolation, independent least squares, PSD projection, margin feasibility, tied-branch derivatives and transported factor actions as applicable, plus bilingual structure. All eight programs use NumPy 1.26.4; teaching calculations, not image benchmarks.
- Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
- Computed bilingual Matplotlib 3.9.1 charts bind both SVGs and numerical samples. Teacher probabilities, hidden-only reconstruction display and declared-basis Jacobians come from executed article functions; shared color scales and interpretation limits are explicit.
Source locations checked:
- Towards a Definition of Disentangled Representations — arXiv v1 · Physical pages 11–12, Sections 5.1–5.2: factor decomposition, equivariance, and explicit permission for subspaces not aligned to a given basis.
- Challenging Common Assumptions in the Unsupervised Learning of Disentangled Representations · Physical page 3, Theorem 1 and surrounding assumptions: continuous factorized latent setting, distribution-preserving factor mixing and inductive-bias/supervision scope.
Related topics