Definition
The unit -sphere: , an -dimensional manifold (dimension one less than the ambient space, since one degree of freedom is fixed by the norm constraint). For a -dimensional activation space, the relevant sphere is .
Intuition
Constraining every point in a -dimensional space to have the same distance from the origin removes exactly one degree of freedom, leaving a -dimensional curved surface — the higher-dimensional analogue of how the surface of a globe is a curved 2D surface embedded in 3D space, even though every point on it is equally far from the center.
Properties
- Constant positive curvature. has constant sectional curvature for a sphere of radius (curvature for the unit sphere), the unique simply-connected space form of constant positive curvature.
- Simply connected for . and for — every loop can be contracted to a point. (The case , , is the exception — see Circle.)
- Geodesics are great circles. The shortest path between two points on lies on the great circle through them (the intersection of with the 2-plane through both points and the origin). Geodesic distance is for points on a sphere of radius .
- Normalisation projects onto . Any map of the form sends all of onto the sphere of radius ; every point that shares a direction with maps to the same image.
- Cosine similarity is the natural inner product on the sphere. For unit vectors , where is the angle between them — equivalently, the geodesic distance is a monotonic function of cosine similarity, , so ranking by cosine similarity and ranking by geodesic distance agree exactly.
- Volume concentration in high dimension. As , the surface measure of concentrates increasingly sharply near any equator (a manifestation of measure concentration in high dimensions) — most of the sphere’s surface area lies within a thin band around any fixed great circle.
Key evidence
Wang & Isola (ICML 2020, arXiv:2005.10242) prove that contrastive
representation learning’s success on the hypersphere decomposes
exactly into two geometric quantities: an alignment loss (positive
pairs close together) and a uniformity loss whose population-level
minimizer is provably, via classical sphere-packing/potential theory,
the uniform distribution on itself — the
strongest possible “no wasted volume” claim about a normalized
representation’s distributional shape, beyond any single point’s norm
or any pair’s angle. Training directly on the two decomposed losses,
with no contrastive term, causally reproduces standard contrastive
pretraining’s downstream performance (67.69% vs. 67.5% ImageNet
linear-probe top-1, ResNet-50/MoCo v2). See
contrastive-loss-asymptotically-optimizes-alignment-and-hypersphere-uniformity
via Alignment/Uniformity Loss Decomposition.
Exercises
Base
- If has , what is , and what is ?
Solution
, and — normalisation always produces a unit-norm vector, by construction, regardless of the original norm (as long as it’s nonzero).
- Two unit vectors satisfy . What is the angle between them, and what is their geodesic distance on (unit sphere)?
Solution
(90°). Geodesic distance on the unit sphere is .
Middle
- Show that for unit vectors , the Euclidean (chord) distance is a monotonically increasing function of the geodesic distance , so that ranking points by chord distance and by geodesic distance agree.
Solution
, where is the geodesic distance. Since is strictly decreasing on , is strictly increasing in , and is a monotonic (increasing, since square root is monotonic on non-negative reals) function of . Hence chord distance and geodesic distance induce the same ordering on any set of unit vectors.
- A vector is decomposed as . Under the map , show that all positive scalar multiples of (i.e. ) map to the same point on , and describe the fibers of this map geometrically.
Solution
For : — the cancels, so every positive multiple of maps to the same normalized point. The fibers of (restricted to ) are exactly the open rays from the origin, each ray mapping to a single point on the sphere — this is precisely the projection from Cone Exercise 6, restricted to positive only (a half-line rather than a full line).
Pro
- Prove that is simply connected for (i.e. every loop can be continuously contracted to a point), using a covering argument sketch: why does the argument fail for ?
Solution
Sketch: any continuous loop can, for , be perturbed (via a small homotopy) to miss at least one point — this is possible because a 1-dimensional image (the loop) generically fails to cover an -dimensional space when (a transversality/dimension-counting argument: a 1-parameter family cannot generically fill an -dimensional target). Once the loop misses a point , is homeomorphic to via stereographic projection, and is contractible, so the loop can be contracted within . For , minus a point is homeomorphic to , which is contractible too — but the argument’s first step fails: a loop on (a 1-dimensional space) generically cannot be perturbed to miss a point while staying a loop that winds around, since a “generic” loop in a 1-dimensional space already covers an open set densely by dimension-counting parity; concretely, the winding-number loops (going around times) are not homotopic to a point-missing configuration without changing the winding number itself, which is exactly the obstruction records.
- Post-LayerNorm activations satisfy for per-example mean and std , then a learned affine rescale . Explain precisely why the rescaled output does not, in general, still lie exactly on a sphere, and under what special case on it would.
Solution
(after mean-subtraction and division by ) lies on a sphere of fixed radius (depending on the normalization convention), but applies a coordinate-wise scale and shift . A coordinate-wise (non-uniform) scale by turns a sphere into an ellipsoid in general (each axis stretched by a different factor ), and adding translates it off-center — an ellipsoid centered away from the origin is not a sphere centered at the origin. The output lies exactly on a (possibly different) sphere centered at the origin only in the special case and (the same constant) for every coordinate — i.e. is a uniform scalar rather than a per-coordinate vector, and there’s no additive shift.