Introduction
In the past decade of machine learning research, many classification models have relied heavily on the availability of a large amount of labeled data [30 , 19 , 51 ] . However, it is not always possible to obtain sufficient labeled data for scaling up models, prompting researchers to leverage vast amounts of unlabeled data [37 , 13 , 11 , 50 , 21 , 28 , 7 , 60 ] , with self-supervised learning emerging as a promising path to advance machine learning (Balestriero
©year Jialiang Wang, Qing Ma, Xiong Zhou, Gangfeng Hu, Haoliang Li and Xianming Liu.
License: CC-BY 4.0, see https://creativecommons.org/licenses/by/4.0/. Attribution requirements are provided at http://jmlr.org/papers/volume/paperid.html. et al., 2023). In particular, we focus on contrastive learning that captures semantically relevant and discriminative information from the data by bringing the representations of positive pairs closer together while pushing the representations of negative samples apart [14 , 20 , 48 , 3 , 22 , 44 ] .
Despite the empirical success of contrastive learning [36 , 34 , 42 , 59 , 58 ] , there remains a lack of comprehensive understanding regarding how this paradigm effectively learns meaningful representations that facilitate downstream tasks [49 , 10 , 5 , 47 , 52 ] . For instance, Kang et al. [27 ] observed that contrastive learning can achieve a balanced representation space in the presence of class imbalance, but there has been limited theoretical analysis of this phenomenon . Due to the absence of supervision, contrastive learning primarily relies on the intrinsic structure within the data [49 , 32 ] , and the inductive biases of the function class and training algorithm [56 , 46 , 16 , 41 ] . However, without further assumptions on the data or inductive biases, relying solely on contrastive losses may not adequately establish relevant associations for downstream behaviors.
Prior studies have introduced various data assumptions to bridge this gap, including the (nearly) conditional independence between positive samples [45 , 31 , 64 ] , the overlap of augmentation sets for semantically similar samples [17 , 54 ] , the expansion or concentration within augmentation sets [55 , 24 ] , and the label consistency of positive pairs [60 ] . While these studies pursue more practical and less restrictive data assumptions to understand contrastive learning, Saunshi et al. [46 ] pointed out that data assumptions alone, even with a small contrastive loss, are insufficient to capture the success of contrastive learning in realistic scenarios. They further argue that understanding contrastive learning requires incorporating inductive biases of the function class. This has motivated studies to investigate constrained function classes, such as assumptions regarding the ability to implement stronger inner-cluster connections [16 ] , cluster-preserving representations [41 ] , and centered representations [6 ] . In light of these two lines of research, several critical questions arise:
Do prior data assumptions that appear distinct essentially characterize or constrain a common aspect? Is there a measure that connects these data assumptions?
Can this measure effectively describe the inductive biases of the function class or training algorithm?
Can we further establish a generalization bound based on this measure without requiring additional assumptions, thus providing a unified framework for studying both data assumptions and inductive biases?
Can we further explore the downstream behaviors of contrastive learning, including its handling of class imbalance and its optimality?
We answer these questions affirmatively. The core insight lies in the observation that prior assumptions essentially or partially describe the interconnections among representations of samples, augmentations, and latent clusters. To quantify these interconnections, we propose the measure of internal discrepancy , denoted by Disc ( f ) \operatorname{Disc}(f) Disc ( f ) , which characterizes the discrepancy between the mean representation of positive samples and latent cluster centers. Without relying on specific assumptions, we prove an internal discrepancy-aware generalization bound on downstream supervised performance for contrastive learning, expressed informally as L s u p ( f ^ ) ≲ L c o n ( f ) + Disc ( f ^ ) + G e n M \mathcal{L}_{\mathrm{sup}}(\hat{f}) \lesssim\mathcal{L}_{\mathrm{con}}(f) + \operatorname{Disc}(\hat{f}) + \mathrm{Gen}_{M} L sup ( f ^ ) ≲ L con ( f ) + Disc ( f ^ ) + Gen M for any f ∈ F f \in\mathcal{F} f ∈ F . Here, L s u p ( f ^ ) \mathcal{L}_{\mathrm{sup}}(\hat{f}) L sup ( f ^ ) is a supervised loss w.r.t. the empirical minimizer f ^ \hat{f} f ^ , L c o n ( f ) \mathcal{L}_{\mathrm{con}}(f) L con ( f ) represents the contrastive loss, and G e n M \mathrm{Gen}_{M} Gen M denotes the generalization error. This bound suggests that downstream performance will be determined by both the value of the contrastive loss and the internal discrepancy. By further establishing the association between specific assumptions and the internal discrepancy, we can readily develop theoretical insights into downstream tasks with those assumptions. Replacing Disc ( f ^ ) \operatorname{Disc}(\hat{f}) Disc ( f ^ ) with the intra-class discrepancy of f f f and the positive-pair alignment of f ^ \hat{f} f ^ in the bound motivates us to minimize an approximation of the internal discrepancy, namely the relaxed k k k -means loss , which aims to reduce the distance between representations within a truncated range.
Moreover, the supervised loss L s u p ( f ^ ) \mathcal{L}_{\mathrm{sup}}(\hat{f}) L sup ( f ^ ) corresponds to a specific supervised loss function, which we refer to as a contrastive learning-incurred supervised loss . Based on the incurred supervised loss, we provide insights into the downstream behaviors of contrastive learning, specifically through the InfoNCE loss [39 ] and the spectral contrastive loss (SpeCL) [17 ] . In class-imbalanced scenarios, we prove that the InfoNCE-incurred loss approximates the balanced softmax loss [43 ] that accommodates class distribution shifts to mitigate class imbalance, and that the cosine similarities between representations learned by the SpeCL-incurred loss remain consistent regardless of the class distribution. These results help explain why contrastive learning can facilitate class-imbalanced learning. Furthermore, we explore the optimality of these contrastive learning-incurred supervised losses, proving that representations learned under the InfoNCE-incurred loss exhibit variability collapse and converge to a simplex equiangular tight frame. Additionally, the SpeCL-incurred loss leads to optimal features that achieve the best approximation of the identity matrix.
Our main contributions are as follows:
We prove the optimality of contrastive learning through its incurred supervised losses, including variability collapse and convergence to a simplex equiangular tight frame for the InfoNCE-incurred loss, and the best approximation to the identity matrix by optimal representations for the SpeCL-incurred loss.
Preliminaries
Notation. Let X \mathcal{X} X denote the set of all possible data points, Y \mathcal{Y} Y be the total label space, and F \mathcal{F} F be the function class of norm-bounded representation functions f : X → R d f:\mathcal{X}\to\mathbb{R}^{d} f : X → R d s.t. ∥ f ( ⋅ ) ∥ ≤ R \lVert f(\cdot)\rVert\leq R ∥ f ( ⋅ )∥ ≤ R for some R > 0 R>0 R > 0 . We define D \mathcal{D} D as the distribution of samples3 , D c \mathcal{D}^{c} D c as its component w.r.t. class c c c , and D T \mathcal{D}_{\mathcal{T}} D T as the joint distribution of samples and their corresponding labels within the (latent) class space T ⊆ Y \mathcal{T}\subseteq\mathcal{Y} T ⊆ Y . Let ρ T \rho_{\mathcal{T}} ρ T be the class distribution of T \mathcal{T} T and ∣ T ∣ \lvert\mathcal{T}\rvert ∣ T ∣ be the cardinality of T \mathcal{T} T . Throughout, we assume ∣ T ∣ ≥ 2 \lvert\mathcal{T}\rvert\geq2 ∣ T ∣ ≥ 2 and ρ T ( c ) > 0 \rho_{\mathcal{T}}(c)>0 ρ T ( c ) > 0 for all c ∈ T c\in\mathcal{T} c ∈ T . We further assume that each sample x ∼ D x\sim\mathcal{D} x ∼ D has a deterministic label y y y , and write ( x , y ) ∼ D T (x,y)\sim\mathcal{D}_{\mathcal{T}} ( x , y ) ∼ D T for brevity.
Supervised Loss. The loss incurred by the classifier g : X → R ∣ T ∣ g:\mathcal{X}\to\mathbb{R}^{\lvert\mathcal{T}\rvert} g : X → R ∣ T ∣ on a point ( x , y ) ∼ D T (x,y)\sim\mathcal{D}_{\mathcal{T}} ( x , y ) ∼ D T is defined as h ( g ( x ) y , { g ( x ) c } c ∈ T , c ≠ y ) h\left(g(x)_{y},\{g(x)_{c}\}_{c\in\mathcal{T},c\neq y}\right) h ( g ( x ) y , { g ( x ) c } c ∈ T , c = y ) , typically tailored for enlarging the prediction g ( x ) y g(x)_{y} g ( x ) y of the target class while reducing the predictions for non-target classes { g ( x ) c } c ≠ y \{g(x)_{c}\}_{c\neq y} { g ( x ) c } c = y . Consequently, the supervised loss w.r.t. the classifier g g g is
L s u p ( D T , g , h ) = E ( x , y ) ∼ D T [ h ( g ( x ) y , { g ( x ) c } c ∈ T , c ≠ y ) ] . (1) L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},g,h)=\mathbb{E}_{(x,y)\sim\mathcal{D}_{\mathcal{T}}}\left[h\left(g(x)_{y},\{g(x)_{c}\}_{c\in\mathcal{T},c\neq y}\right)\right]. \tag*{(1)} L sup ( D T , g , h ) = E ( x , y ) ∼ D T [ h ( g ( x ) y , { g ( x ) c } c ∈ T , c = y ) ] . (1)
Linear Probing. To evaluate the downstream classification performance of the representation model f f f , we train a linear classifier W ∈ R ∣ T ∣ × d W\in\mathbb{R}^{\lvert\mathcal{T}\rvert\times d} W ∈ R ∣ T ∣ × d and use g ( x ) = W f ( x ) g(x)=Wf(x) g ( x ) = W f ( x ) to calculate the classification loss L s u p ( D T , W f , h ) L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},Wf,h) L sup ( D T , W f , h ) . By fixing f f f and optimizing the linear classifier, we use a slight abuse of notation and define the supervised loss of f f f on D T \mathcal{D}_{\mathcal{T}} D T as the infimum over W W W :
L s u p ( D T , f , h ) = inf W ∈ R ∣ T ∣ × d L s u p ( D T , W f , h ) . (2) L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},f,h)=\inf_{W\in\mathbb{R}^{\lvert\mathcal{T}\rvert\times d}}L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},Wf,h). \tag*{(2)} L sup ( D T , f , h ) = W ∈ R ∣ T ∣ × d inf L sup ( D T , W f , h ) . (2)
Since L s u p ( D T , f , h ) ≤ L s u p ( D T , W f , h ) L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},f,h)\leq L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},Wf,h) L sup ( D T , f , h ) ≤ L sup ( D T , W f , h ) for any W W W , we focus on bounding a surrogate classification loss with the mean classifier that comprises class means of representations ([45 , 54 , 24 , 26 ] ). Throughout this paper, unless otherwise specified, W W W is the mean classifier, i.e., w c = E x ∼ D c f ( x ) w_{c}=\mathbb{E}_{x\sim\mathcal{D}^{c}}f(x) w c = E x ∼ D c f ( x ) for all c ∈ T c\in\mathcal{T} c ∈ T .
Contrastive Learning. Contrastive learning is based on the fundamental idea of bringing representations of positive pairs closer while pushing representations of negative samples apart. We model an anchor x x x and its positive sample x + x^{+} x + by the joint distribution D p o s ( x , x + ) = D ( x ) D p o s ( x + ∣ x ) \mathcal{D}_{\mathrm{pos}}(x,x^{+})=\mathcal{D}(x)\mathcal{D}_{\mathrm{pos}}(x^{+}\mid x) D pos ( x , x + ) = D ( x ) D pos ( x + ∣ x ) 4 , and k ≥ 1 k\geq1 k ≥ 1 negative samples { x i − } i = 1 k \{x_{i}^{-}\}_{i=1}^{k} { x i − } i = 1 k are drawn i.i.d. from D n e g ( x − ∣ x ) \mathcal{D}_{\mathrm{neg}}(x^- \mid x) D neg ( x − ∣ x ) .5 The population contrastive loss is defined as
L c o n ( f , D ; ℓ ) = E x , x + ∼ D p o s { x i − } i = 1 k ∼ i . i . d . D n e g ℓ ( f , x , x + , { x i − } i = 1 k ) . (3) L_{\mathrm{con}}(f,\mathcal{D};\ell)=\mathbb{E}_{\substack{x,x^+\sim\mathcal{D}_{\mathrm{pos}}\\ \{x_i^-\}_{i=1}^k\overset{\mathrm{i.i.d.}}{\sim}\mathcal{D}_{\mathrm{neg}}}}\ell\left(f,x,x^+,\{x_i^-\}_{i=1}^k\right). \tag*{(3)} L con ( f , D ; ℓ ) = E x , x + ∼ D pos { x i − } i = 1 k ∼ i.i.d. D neg ℓ ( f , x , x + , { x i − } i = 1 k ) . (3)
where ℓ \ell ℓ represents the contrastive loss function. For the sake of brevity, we will use ℓ ( f , x , x + , { x i − } i = 1 k ) \ell\left(f,x,x^+,\{x_i^-\}_{i=1}^k\right) ℓ ( f , x , x + , { x i − } i = 1 k ) to denote ℓ ( f ( x ) ⊤ f ( x + ) , { f ( x ) ⊤ f ( x i − ) } i = 1 k ) \ell\left(f(x)^\top f(x^+),\{f(x)^\top f(x_i^-)\}_{i=1}^k\right) ℓ ( f ( x ) ⊤ f ( x + ) , { f ( x ) ⊤ f ( x i − ) } i = 1 k ) . Additionally, we might abbreviate L c o n ( f , D ; ℓ ) L_{\mathrm{con}}(f,\mathcal{D};\ell) L con ( f , D ; ℓ ) as L c o n ( f ; ℓ ) L_{\mathrm{con}}(f;\ell) L con ( f ; ℓ ) or L c o n ( f ) L_{\mathrm{con}}(f) L con ( f ) in certain contexts. Intuitively, the essence of minimizing the contrastive loss lies in amplifying the similarity between positive-pair representations f ( x ) f(x) f ( x ) and f ( x + ) f(x^+) f ( x + ) , while striving to separate the representations of negative samples. Correspondingly, Wang and Isola (2020) have identified two properties related to this process: the alignment of positive pairs and the uniformity of features.
We exemplify two contrastive loss functions below. The first is the widely used InfoNCE loss:
Example 1 (InfoNCE). The InfoNCE loss in contrastive learning (Oord et al., [39 ] ; Chen et al., [4 ] ; He et al., 2020}) is defined as ℓ ( f , x , x + , { x i − } i = 1 k ) = log [ 1 + ∑ i = 1 k exp ( f ( x ) ⊤ ( f ( x i − ) − f ( x + ) ) ) ] \ell\left(f,x,x^+,\{x_i^-\}_{i=1}^k\right)=\log\left[1+\sum_{i=1}^k\exp\left(f(x)^\top\left(f(x_i^-)-f(x^+)\right)\right)\right] ℓ ( f , x , x + , { x i − } i = 1 k ) = log [ 1 + ∑ i = 1 k exp ( f ( x ) ⊤ ( f ( x i − ) − f ( x + ) ) ) ] .
The second is the spectral contrastive loss that is both sample-contrastive and dimension-contrastive (HaoChen et al., [17 ] ; HaoChen and Ma, [16 ] ; HaoChen et al., [18 ] ; Balestriero and LeCun, [1 ] ; Zhou et al., [63 ] ), acting as a well-established theoretical surrogate for the InfoNCE loss:
Example 2 (Spectral Contrastive Loss (SpeCL)). The spectral contrastive loss (HaoChen et al., 2021}) is formulated as ℓ ( f , x , x + , { x i − } i = 1 k ) = − 2 f ( x ) ⊤ f ( x + ) + 1 k ∑ i = 1 k ( f ( x ) ⊤ f ( x i − ) ) 2 \ell\left(f,x,x^+,\{x_i^-\}_{i=1}^k\right)=-2f(x)^\top f(x^+)+\frac{1}{k}\sum_{i=1}^k\left(f(x)^\top f(x_i^-)\right)^2 ℓ ( f , x , x + , { x i − } i = 1 k ) = − 2 f ( x ) ⊤ f ( x + ) + k 1 ∑ i = 1 k ( f ( x ) ⊤ f ( x i − ) ) 2 .
As detailed in Appendix A.§ 1 , the separate convexity of the InfoNCE loss and the spectral contrastive loss can be easily verified w.r.t. the representations f ( x ) f(x) f ( x ) , f ( x + ) f(x^+) f ( x + ) , and f ( x i − ) f(x_i^-) f ( x i − ) . Furthermore, these two loss functions are also Lipschitz continuous when f f f adheres to bounded norm constraints. Therefore, we consider contrastive loss functions with both convexity and Lipschitzness.
For the tuples { ( x j , x j + , { x j i − } i = 1 k ) } j = 1 M \left\{\left(x_j,x_j^+,\{x_{ji}^-\}_{i=1}^k\right)\right\}_{j=1}^M { ( x j , x j + , { x j i − } i = 1 k ) } j = 1 M drawn i.i.d. according to the sampling scheme above, the empirical counterpart is defined as
L ^ c o n ( f ) = 1 M ∑ j = 1 M ℓ ( f , x j , x j + , { x j i − } i = 1 k ) . (4) \widehat{L}_{\mathrm{con}}(f)=\frac{1}{M}\sum_{j=1}^M\ell\left(f,x_j,x_j^+,\{x_{ji}^-\}_{i=1}^k\right). \tag*{(4)} L con ( f ) = M 1 j = 1 ∑ M ℓ ( f , x j , x j + , { x j i − } i = 1 k ) . (4)
The goal of contrastive learning is to identify the risk minimizer f ∗ ∈ arg min f ∈ F L c o n ( f , D ) f^*\in\arg\min_{f\in\mathcal{F}}L_{\mathrm{con}}(f,\mathcal{D}) f ∗ ∈ arg min f ∈ F L con ( f , D ) . In practical scenarios, where access is limited to a finite number of samples, our focus pivots towards finding the empirical risk minimizer f ^ ∈ arg min f ∈ F L ^ c o n ( f ) \widehat{f}\in\arg\min_{f\in\mathcal{F}}\widehat{L}_{\mathrm{con}}(f) f ∈ arg min f ∈ F L con ( f ) . As in supervised learning, the generalization bound for contrastive learning is measured by the difference between f ^ \widehat{f} f and f ∗ f^* f ∗ , but with a greater emphasis on bounding the downstream supervised loss L s u p ( D T , W f ^ , h ) L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},W_{\widehat{f}},h) L sup ( D T , W f , h ) for some W W W .
Internal Discrepancy for Contrastive Learning
In this section, we begin by introducing the concept of internal discrepancy and its relationship to various assumptions outlined in the literature. Following this, we establish an internal discrepancy-aware generalization bound for contrastive learning, which does not rely on any specific data assumptions. Moreover, we propose the relaxed k-means loss as a means to approximate the minimization of internal discrepancy. Additional results for scenarios involving a single negative sample are provided in Appendix B.
Internal Discrepancy
Despite the empirical success of contrastive learning, a significant gap persists in theoretical understanding of how this paradigm effectively learns meaningful relationships between data points. Due to the absence of labels in the data, contrastive learning primarily relies on the associations within the data and their augmentations, and the inductive biases of the function class. Prior studies have presented various data assumptions to establish relevant theories, such as conditional independence of positive pairs [45 , 31 , 64 ] and the overlap of augmentation sets [17 , 54 ] . They have also considered assumptions on the function class, including centered representations [6 ] . While diverse, these assumptions essentially or at least partially describe interconnections between samples, augmentations, and latent clusters.
To essentially measure these interconnections, we define the internal discrepancy as follows:
Definition 1 (Internal Discrepancy). For the data distribution D \mathcal{D} D with latent classes T \mathcal{T} T , the internal discrepancy is defined as follows:
Disc ( f ) = E c ∼ ρ T E x ∼ D c ∥ E x + ∼ D p o s ( ⋅ ∣ x ) f ( x + ) − E x ∼ D c f ( x ) ∥ , (5) \operatorname{Disc}(f) = \mathbb{E}_{c\sim\rho_{\mathcal{T}}}\mathbb{E}_{x\sim\mathcal{D}_c}\left\lVert\mathbb{E}_{x^+\sim\mathcal{D}_{\mathrm{pos}}(\cdot\mid x)}f(x^+) - \mathbb{E}_{x\sim\mathcal{D}_c}f(x)\right\rVert, \tag*{(5)} Disc ( f ) = E c ∼ ρ T E x ∼ D c E x + ∼ D pos ( ⋅ ∣ x ) f ( x + ) − E x ∼ D c f ( x ) , (5) where ∥ ⋅ ∥ \lVert\cdot\rVert ∥ ⋅ ∥ denotes the ℓ 2 \ell_2 ℓ 2 -norm.
Internal discrepancy quantitatively characterizes the alignment between the mean representation of positive samples of a data point and the classwise mean representation. Moreover, we have:
Disc ( f ) ≤ E x , x + ∼ D p o s ( x , x + ) ∥ f ( x + ) − f ( x ) ∥ ⏟ positive-pair alignment Disc a ( f ) + E c ∼ ρ T E x ∼ D c ∥ f ( x ) − E x ∼ D c f ( x ) ∥ ⏟ intra-class discrepancy Disc i ( f ) (6) \operatorname{Disc}(f) \leq\underbrace{\mathbb{E}_{x,x^+\sim\mathcal{D}_{\mathrm{pos}}(x,x^+)}\lVert f(x^+) - f(x)\rVert}_{\text{positive-pair alignment }\operatorname{Disc}_{a}(f)} + \underbrace{\mathbb{E}_{c\sim\rho_{\mathcal{T}}}\mathbb{E}_{x\sim\mathcal{D}_c}\left\lVert f(x)-\mathbb{E}_{x\sim\mathcal{D}_c}f(x)\right\rVert}_{\text{intra-class discrepancy }\operatorname{Disc}_{i}(f)} \tag*{(6)} Disc ( f ) ≤ positive-pair alignment Disc a ( f ) E x , x + ∼ D pos ( x , x + ) ∥ f ( x + ) − f ( x )∥ + intra-class discrepancy Disc i ( f ) E c ∼ ρ T E x ∼ D c ∥ f ( x ) − E x ∼ D c f ( x ) ∥ (6)
which implies that internal discrepancy is further governed by two key components: the positive-pair alignment term Disc a ( f ) \operatorname{Disc}_{a}(f) Disc a ( f ) , also referred to as the alignment loss [53 ] , and the intra-class discrepancy Disc i ( f ) \operatorname{Disc}_{i}(f) Disc i ( f ) that measures the discrepancy between the representations of individual samples and their respective latent class means. While prior works often posit specific assumptions that appear distinct, we demonstrate that they essentially serve as conditions to constrain the value of internal discrepancy Disc ( f ) \operatorname{Disc}(f) Disc ( f ) or the two terms in its upper bound. Figure 1 illustrates a configuration in which more compact class clouds and local positive-pair regions accompany a smaller distance between the conditional positive mean and the class mean, reducing internal discrepancy.
Figure 1. Schematic comparison of large and small internal discrepancy. Colors denote latent classes, while dashed regions highlight local positive pairs. The filled and open circles indicate f ( x ) f(x) f ( x ) and f ( x + ) f(x^+) f ( x + ) . The diamond and star mark E x + ∼ D p o s ( ⋅ ∣ x ) f ( x + ) \mathbb{E}_{x^+\sim\mathcal{D}_{\mathrm{pos}}(\cdot\mid x)}f(x^+) E x + ∼ D pos ( ⋅ ∣ x ) f ( x + ) and E x ∼ D c f ( x ) \mathbb{E}_{x\sim\mathcal{D}_c}f(x) E x ∼ D c f ( x ) , respectively. The expected distance between the conditional positive mean and the class mean equals Disc ( f ) \operatorname{Disc}(f) Disc ( f ) . The right panel depicts more compact class and local regions, accompanied by a shorter segment in the illustrated configuration.
Association with Previous Assumptions. The internal discrepancy metric provides a novel perspective for integrating and expanding upon assumptions made in prior literature regarding data characteristics [45 , 54 , 24 , 60 ] and the function class [16 , 41 , 6 ] :
(i) The assumption of conditional independence of positive-pair draws [45 ] states that D p o s ( x , x + ∣ c ) = D c ( x ) D c ( x + ) \mathcal{D}_{\mathrm{pos}}(x,x^+\mid c)=\mathcal{D}^{c}(x)\mathcal{D}^{c}(x^+) D pos ( x , x + ∣ c ) = D c ( x ) D c ( x + ) . This leads to a zero internal discrepancy (Disc ( f ) = 0 \operatorname{Disc}(f)=0 Disc ( f ) = 0 ), as E x + ∼ D p o s ( ⋅ ∣ x ) f ( x + ) = E x ∼ D c f ( x ) \mathbb{E}_{x^+\sim\mathcal{D}_{\mathrm{pos}}(\cdot\mid x)}f(x^+)=\mathbb{E}_{x\sim\mathcal{D}_c}f(x) E x + ∼ D pos ( ⋅ ∣ x ) f ( x + ) = E x ∼ D c f ( x ) .
(ii) The perfect alignment assumption between positive pairs (or the augmentation-invariant assumption) [54 Assumption 4.6] implies f ( x ) = f ( x + ) f(x)=f(x^+) f ( x ) = f ( x + ) for all x , x + ∼ D p o s ( x , x + ) x,x^+\sim\mathcal{D}_{\mathrm{pos}}(x,x^+) x , x + ∼ D pos ( x , x + ) , that is, Disc a ( f ) = 0 \operatorname{Disc}_a(f)=0 Disc a ( f ) = 0 . Moreover, the internal discrepancy Disc ( f ) \operatorname{Disc}(f) Disc ( f ) simplifies to the intra-class discrepancy E c ∼ ρ T E x ∼ D c ∥ f ( x ) − E x ∼ D c f ( x ) ∥ \mathbb{E}_{c\sim\rho_T}\mathbb{E}_{x\sim\mathcal{D}_c}\lVert f(x)-\mathbb{E}_{x\sim\mathcal{D}_c}f(x)\rVert E c ∼ ρ T E x ∼ D c ∥ f ( x ) − E x ∼ D c f ( x )∥ , quantified as the expected distance between each sample and its corresponding class mean.
(iii) The ( σ , δ ) (\sigma,\delta) ( σ , δ ) -augmentation described by Huang et al. [24 ] means that for each class, whose sample set is G c G_c G c , there exists a subset G c 0 ⊆ G c G_c^0\subseteq G_c G c 0 ⊆ G c such that P [ x ∈ G c 0 ] ≥ σ P [ x ∈ G c ] \mathbb{P}[x\in G_c^0]\geq\sigma\mathbb{P}[x\in G_c] P [ x ∈ G c 0 ] ≥ σ P [ x ∈ G c ] with σ ∈ ( 0 , 1 ] \sigma\in(0,1] σ ∈ ( 0 , 1 ] and sup x 1 , x 2 ∈ G c 0 d A ( x 1 , x 2 ) ≤ δ \sup_{x_1,x_2\in G_c^0}d_A(x_1,x_2)\leq\delta sup x 1 , x 2 ∈ G c 0 d A ( x 1 , x 2 ) ≤ δ , where d A ( x 1 , x 2 ) = min x 1 ′ ∈ A ( x 1 ) , x 2 ′ ∈ A ( x 2 ) ∥ x 1 ′ − x 2 ′ ∥ d_A(x_1,x_2)=\min_{x'_1\in A(x_1),x'_2\in A(x_2)}\lVert x'_1-x'_2\rVert d A ( x 1 , x 2 ) = min x 1 ′ ∈ A ( x 1 ) , x 2 ′ ∈ A ( x 2 ) ∥ x 1 ′ − x 2 ′ ∥ for augmentation A A A . Under the additional assumptions of ϵ \epsilon ϵ -close representations among augmented data (∥ f ( x 1 ) − f ( x 2 ) ∥ ≤ ϵ \lVert f(x_1)-f(x_2)\rVert\leq\epsilon ∥ f ( x 1 ) − f ( x 2 )∥ ≤ ϵ for all x 1 , x 2 ∈ A ( x ) x_1,x_2\in A(x) x 1 , x 2 ∈ A ( x ) ) and ι \iota ι -Lipschitzness of f f f in Huang et al. [24 ] , we obtain Disc ( f ) ≤ σ 2 ( ι δ + 2 ϵ ) + 2 R ( 1 − σ 2 ) \operatorname{Disc}(f)\leq\sigma^2(\iota\delta+2\epsilon)+2R(1-\sigma^2) Disc ( f ) ≤ σ 2 ( ιδ + 2 ϵ ) + 2 R ( 1 − σ 2 ) .
(iv) The F-implementable inner-cluster connection larger than β \beta β assumption HaoChen and Ma [16 ] (Assumption 3.3) implies E x , x + ∼ D p o s c ∥ f ( x + ) − f ( x ) ∥ 2 ≥ β E x ∼ D c ∥ f ( x ) − E x ∼ D c f ( x ) ∥ 2 \mathbb{E}_{x,x^+\sim D_{\mathrm{pos}}^c}\|f(x^+)-f(x)\|^2 \geq\beta\mathbb{E}_{x\sim D^c}\|f(x)-\mathbb{E}_{x\sim D^c}f(x)\|^2 E x , x + ∼ D pos c ∥ f ( x + ) − f ( x ) ∥ 2 ≥ β E x ∼ D c ∥ f ( x ) − E x ∼ D c f ( x ) ∥ 2 for any f ∈ F f\in\mathcal{F} f ∈ F . Then we can derive that Disc ( f ) ≤ Disc a ( f ) + 1 β E c ∼ ρ T E x , x + ∼ D p o s c ∥ f ( x + ) − f ( x ) ∥ 2 \operatorname{Disc}(f)\leq\operatorname{Disc}_a(f)+\frac{1}{\sqrt{\beta}}\sqrt{\mathbb{E}_{c\sim\rho_T}\mathbb{E}_{x,x^+\sim D_{\mathrm{pos}}^c}\|f(x^+)-f(x)\|^2} Disc ( f ) ≤ Disc a ( f ) + β 1 E c ∼ ρ T E x , x + ∼ D pos c ∥ f ( x + ) − f ( x ) ∥ 2 , which measures the divergence between representations of positive pairs.
(v) For the cluster-preserving function class Parulekar et al. [41 ] (Definition 4.1) satisfying f ( x ) = f ( x ′ ) f(x)=f(x') f ( x ) = f ( x ′ ) for all x , x ′ ∼ i . i . d . D c x,x'\mathrel{\overset{\mathrm{i.i.d.}}{\sim}}D^c x , x ′ ∼ i.i.d. D c , c ∈ T c\in\mathcal{T} c ∈ T and f ∈ F f\in\mathcal{F} f ∈ F , Disc ( f ) = E x ∼ D ∥ f ( x ) − E x + ∼ D p o s ( ⋅ ∣ x ) f ( x + ) ∥ ≤ Disc a ( f ) \operatorname{Disc}(f)=\mathbb{E}_{x\sim D}\|f(x)-\mathbb{E}_{x^+\sim D_{\mathrm{pos}}(\cdot\mid x)}f(x^+)\|\leq\operatorname{Disc}_a(f) Disc ( f ) = E x ∼ D ∥ f ( x ) − E x + ∼ D pos ( ⋅ ∣ x ) f ( x + ) ∥ ≤ Disc a ( f ) , which means that the internal discrepancy is bounded by the positive-pair alignment term.
(vi) For the label consistency assumption Zhang et al. [60 ] (Assumption 4), positive pairs satisfy P x , x + ∼ D p o s [ y x ≠ y x + ] ≤ α \mathbb{P}_{x,x^+\sim D_{\mathrm{pos}}}[y_x\ne y_{x^+}]\leq\alpha P x , x + ∼ D pos [ y x = y x + ] ≤ α for some α ∈ [ 0 , 1 ] \alpha\in[0,1] α ∈ [ 0 , 1 ] , which yields Disc ( f ) ≤ Disc i ( f ) + 2 R α \operatorname{Disc}(f)\leq\operatorname{Disc}_i(f)+2R\alpha Disc ( f ) ≤ Disc i ( f ) + 2 R α when x + x^+ x + also follows the marginal distribution D D D . This implies that the internal discrepancy is bounded by the intra-class discrepancy and an additional term accounting for positive pairs from different classes. Moreover, the connected intra-class augmentation graphs and ϵ \epsilon ϵ -alignment conditions in Zhang et al. [60 ] (Assumptions 8 and 9) provide a means to control the intra-class discrepancy by propagating alignment along paths within each class.
(vii) For the centered representation assumption Cui et al. [6 ] (Assumption 2.2), the original sample satisfies E x + ∼ D p o s ( ⋅ ∣ x ) f ( x + ) = f ( x ) \mathbb{E}_{x^+\sim D_{\mathrm{pos}}(\cdot\mid x)}f(x^+)=f(x) E x + ∼ D pos ( ⋅ ∣ x ) f ( x + ) = f ( x ) . When D c D^c D c denotes the distribution of original samples in class c c c and D p o s ( ⋅ ∣ x ) D_{\mathrm{pos}}(\cdot\mid x) D pos ( ⋅ ∣ x ) is induced by augmenting the original anchor x x x , we obtain Disc ( f ) = Disc i ( f ) \operatorname{Disc}(f)=\operatorname{Disc}_i(f) Disc ( f ) = Disc i ( f ) directly from the definition. This assumption constrains the mean representation of augmented samples while allowing Disc a ( f ) > 0 \operatorname{Disc}_a(f)>0 Disc a ( f ) > 0 , so that the internal discrepancy reduces to the intra-class discrepancy without requiring the perfect alignment in (ii).
In essence, by formulating a generalization bound that takes into account internal discrepancy as the intermediate bridge, we can readily use specific data assumptions to develop theoretical insights into downstream tasks. This only requires us to establish the association between internal discrepancy and these data assumptions.
Internal Discrepancy-Aware Generalization Bound
We first show that there exists a supervised loss bounded by the population contrastive loss and internal discrepancy:
Theorem 2. For the loss function ℓ \ell ℓ that is convex with respect to each of f ( x + ) f(x^+) f ( x + ) and f ( x i − ) f(x_i^-) f ( x i − ) and η \eta η -Lipschitz w.r.t. the positive representation f ( x + ) f(x^+) f ( x + ) , and the distribution D D D with latent classes T \mathcal{T} T , for all f ∈ F f\in\mathcal{F} f ∈ F , there exist a linear classifier W ∈ R ∣ T ∣ × d W\in\mathbb{R}^{|\mathcal{T}|\times d} W ∈ R ∣ T ∣ × d and a supervised loss h : R ∣ T ∣ × T → R h:\mathbb{R}^{|\mathcal{T}|}\times\mathcal{T}\to\mathbb{R} h : R ∣ T ∣ × T → R such that
L s u p ( D T , W f , h ) ≤ L c o n ( f ; ℓ ) + η ⋅ Disc ( f ) , (7) L_{\mathrm{sup}}(D_{\mathcal{T}},Wf,h)\leq L_{\mathrm{con}}(f;\ell)+\eta\cdot\operatorname{Disc}(f), \tag*{(7)} L sup ( D T , W f , h ) ≤ L con ( f ; ℓ ) + η ⋅ Disc ( f ) , (7) where equality holds if f ( x ) = f ( x + ) = E x ′ ∼ D c f ( x ′ ) f(x)=f(x^+)=\mathbb{E}_{x'\sim D^c}f(x') f ( x ) = f ( x + ) = E x ′ ∼ D c f ( x ′ ) for all x , x + ∼ D p o s c x,x^+\sim D_{\mathrm{pos}}^c x , x + ∼ D pos c and c ∈ T c\in\mathcal{T} c ∈ T . And h ( w y T f ( x ) , { w c T f ( x ) } c ≠ y ) = E { c i } i = 1 k ∼ i . i . d . ρ T ℓ ( f ( x ) , w y , { w c i } i = 1 k ) h(w_y^\mathsf{T}f(x),\{w_c^\mathsf{T}f(x)\}_{c\ne y})=\mathbb{E}_{\{c_i\}_{i=1}^k\mathrel{\overset{\mathrm{i.i.d.}}{\sim}\rho_{\mathcal{T}}}\ell(f(x),w_y,\{w_{c_i}\}_{i=1}^k)} h ( w y T f ( x ) , { w c T f ( x ) } c = y ) = E { c i } i = 1 k ∼ i.i.d. ρ T ℓ ( f ( x ) , w y , { w c i } i = 1 k ) is the incurred supervised loss.
The following proposition shows that the internal discrepancy term in Theorem 2 cannot be dropped, even for a near-minimizer of the contrastive loss:
Proposition 3. For any k ≥ 1 k \ge1 k ≥ 1 , class distribution ρ T \rho_T ρ T , and ϵ > 0 \epsilon> 0 ϵ > 0 with d ≥ ∣ T ∣ ⌈ k 2 ϵ ⌉ d \ge\lvert T\rvert\left\lceil\frac{k}{2\epsilon}\right\rceil d ≥ ∣ T ∣ ⌈ 2 ϵ k ⌉ , there exist a distribution D D D with latent classes T T T and a representation f f f with ∥ f ( x ) ∥ = R \lVert f(x)\rVert= R ∥ f ( x )∥ = R such that, for the InfoNCE loss with η = R \eta= R η = R , positive samples x + = x x^+ = x x + = x , and negative samples drawn from D D D , we have Disc ( f ) = R \operatorname{Disc}(f) = R Disc ( f ) = R , the mean classifier W = 0 W = 0 W = 0 , L c o n ( f ) ≤ inf f ′ L c o n ( f ′ ) + ϵ L_{\mathrm{con}}(f) \le\inf_{f'} L_{\mathrm{con}}(f')+\epsilon L con ( f ) ≤ inf f ′ L con ( f ′ ) + ϵ with the infimum over all f ′ f' f ′ satisfying ∥ f ′ ( x ) ∥ ≤ R \lVert f'(x)\rVert\le R ∥ f ′ ( x )∥ ≤ R , and
L s u p ( D T , W f , h ) = log ( 1 + k ) ≥ L c o n ( f ) + η ⋅ Disc ( f ) − log e R 2 + k 1 + k − ϵ . (8) L_{\mathrm{sup}}(D_T,Wf,h)=\log(1+k)\ge L_{\mathrm{con}}(f)+\eta\cdot\operatorname{Disc}(f)-\log\frac{e^{R^2}+k}{1+k}-\epsilon. \tag*{(8)} L sup ( D T , W f , h ) = log ( 1 + k ) ≥ L con ( f ) + η ⋅ Disc ( f ) − log 1 + k e R 2 + k − ϵ . (8)
Since log e R 2 + k 1 + k ≤ e R 2 − 1 1 + k \log\frac{e^{R^2}+k}{1+k}\le\frac{e^{R^2}-1}{1+k} log 1 + k e R 2 + k ≤ 1 + k e R 2 − 1 , the bound in Theorem 2 becomes tight in this example as k k k grows, with the gap L s u p ( D T , W f , h ) − L c o n ( f ) L_{\mathrm{sup}}(D_T,Wf,h)-L_{\mathrm{con}}(f) L sup ( D T , W f , h ) − L con ( f ) approaching η ⋅ Disc ( f ) \eta\cdot\operatorname{Disc}(f) η ⋅ Disc ( f ) .
Contrastive Learning-Incurred Supervised Loss. The supervised loss h h h incurred by contrastive learning involves an expectation over k k k i.i.d. class draws { c i } i = 1 k \{c_i\}_{i=1}^k { c i } i = 1 k from ρ T \rho_T ρ T and may suffer from class collisions due to the presence of the target-class weight among the negatives. Moreover, the specific form of h h h is intricately tied to factors such as the number of negatives k k k and the latent class distribution ρ T \rho_T ρ T , posing practical challenges in its application. Nevertheless, the incurred loss h h h can be effective for classification problems. For instance, the InfoNCE-incurred supervised loss can be reformulated as h ( W f ( x ) , y ) = ∑ j = 0 k ( k j ) ( ρ T ( y ) ) j ( 1 − ρ T ( y ) ) k − j E { c i } i = 1 k − j ∼ i . i . d . ρ T y [ log ( 1 + j + ∑ i = 1 k − j e f ( x ) ⊤ ( w c i − w y ) ) ] h(Wf(x),y)=\sum_{j=0}^{k}\binom{k}{j}\bigl(\rho_T(y)\bigr)^j\bigl(1-\rho_T(y)\bigr)^{k-j}\mathbb{E}_{\{c_i\}_{i=1}^{k-j}\stackrel{\mathrm{i.i.d.}}{\sim}\rho_T^y}\left[\log\left(1+j+\sum_{i=1}^{k-j}e^{f(x)^\top(w_{c_i}-w_y)}\right)\right] h ( W f ( x ) , y ) = ∑ j = 0 k ( j k ) ( ρ T ( y ) ) j ( 1 − ρ T ( y ) ) k − j E { c i } i = 1 k − j ∼ i.i.d. ρ T y [ log ( 1 + j + ∑ i = 1 k − j e f ( x ) ⊤ ( w c i − w y ) ) ] (where ρ T y \rho_T^y ρ T y denotes the class distribution excluding class y y y ), which explicitly accounts for class collision. This formulation bears similarity to the cross entropy (CE) loss log [ 1 + ∑ c ∈ T , c ≠ y e f ( x ) ⊤ ( w c − w y ) ] \log\left[1+\sum_{c\in T,c\ne y}e^{f(x)^\top(w_c-w_y)}\right] log [ 1 + ∑ c ∈ T , c = y e f ( x ) ⊤ ( w c − w y ) ] . In Figure 2 and Table 1 , we demonstrate that the InfoNCE-incurred loss (we randomly sample k k k classifier weights t t t times) can yield comparable results to CE. Additionally, we prove below that they share the same global minimizers under mild conditions. Further analysis of the incurred loss will be developed in Section 4.
Figure 2. Illustration of validation accuracies (%) on CIFAR-10, CIFAR-100, and ImageNet-100 using cross entropy, InfoNCE-incurred loss as per Theorem 2, and multi-class binary cross entropy defined in Equation (31) . The depicted results demonstrate that these three loss functions deliver comparable performance.
Table 1. Validation accuracies (%) on the CIFAR-10 and CIFAR-100 datasets. These results are obtained through supervised learning using cross entropy (CE) or InfoNCE-incurred loss (with the number of negatives k k k and the number of sampling repetitions t t t ). As is evident from the results, the InfoNCE-incurred supervised loss, when optimized with suitable values of k k k and t t t , can yield performance that is on par with or even surpasses that of the traditional CE approach.
Lemma 4. Consider the class-balanced distribution and the InfoNCE-incurred supervised risk H ( f ) = E ( x , y ) ∼ D T E { c i } i = 1 k ∼ i . i . d . ρ T [ log ( 1 + ∑ i = 1 k e f ( x ) ⊤ ( w c i − w y ) ) ] \mathcal{H}(f)=\mathbb{E}_{(x,y)\sim\mathcal{D}_T}\mathbb{E}_{\{c_i\}_{i=1}^{k}\stackrel{\mathrm{i.i.d.}}{\sim}\rho_T}\left[\log\left(1+\sum_{i=1}^{k}e^{f(x)^\top(w_{c_i}-w_y)}\right)\right] H ( f ) = E ( x , y ) ∼ D T E { c i } i = 1 k ∼ i.i.d. ρ T [ log ( 1 + ∑ i = 1 k e f ( x ) ⊤ ( w c i − w y ) ) ] . If d ≥ ∣ T ∣ − 1 d\ge\lvert T\rvert-1 d ≥ ∣ T ∣ − 1 , then H ( f ) \mathcal{H}(f) H ( f )
and the CE loss E ( x , y ) ∼ D T log [ 1 + ∑ c ≠ y e f ( x ) T ( w c − w y ) ] \mathbb{E}_{(x,y)\sim D_T}\log\left[1+\sum_{c\ne y}e^{f(x)^{\mathsf T}(w_c-w_y)}\right] E ( x , y ) ∼ D T log [ 1 + ∑ c = y e f ( x ) T ( w c − w y ) ] share the same global minimizers over all representation functions satisfying ∥ f ( x ) ∥ ≤ R \lVert f(x)\rVert\le R ∥ f ( x )∥ ≤ R .
While a variety of works have studied the capacity of contrastive learning to recover meaningful representations or latent clusters under certain data assumptions, we put forth a generalization bound for Lipschitz convex losses, which holds without any additional assumptions.
Theorem 5 (Generalization Bound). Under the conditions in Theorem 2 , assume further that ℓ \ell ℓ is η ζ 1 ( R ) \eta\zeta_1(R) η ζ 1 ( R ) -Lipschitz w.r.t. ( f ( x ) , f ( x + ) , { f ( x i − ) } i = 1 k ) (f(x),f(x^+),\{f(x_i^-)\}_{i=1}^{k}) ( f ( x ) , f ( x + ) , { f ( x i − ) } i = 1 k ) and has a range of length at most ζ 2 ( R ) \zeta_2(R) ζ 2 ( R ) . With probability at least 1 − δ 1-\delta 1 − δ , for all f ∈ F f\in\mathcal{F} f ∈ F , there exist a linear classifier W ∈ R ∣ T ∣ × d W\in\mathbb{R}^{|\mathcal{T}|\times d} W ∈ R ∣ T ∣ × d and a supervised loss h h h such that
L s u p ( D T , W ^ f , h ) ≤ L c o n ( f ) + η ⋅ Disc ( f ^ ) + Gen M , (9) L_{\mathrm{sup}}(D_{\mathcal{T}},\widehat{W}f,h)\le L_{\mathrm{con}}(f)+\eta\cdot\operatorname{Disc}(\widehat{f})+\operatorname{Gen}_{\mathrm{M}}, \tag*{(9)} L sup ( D T , W f , h ) ≤ L con ( f ) + η ⋅ Disc ( f ) + Gen M , (9) where Gen M = O ( η ζ 1 ( R ) R S ( F ) M + ζ 2 ( R ) log ( 2 / δ ) M ) \operatorname{Gen}_{\mathrm{M}}=O\left(\frac{\eta\zeta_1(R)R_S(\mathcal{F})}{M}+\zeta_2(R)\sqrt{\frac{\log(2/\delta)}{M}}\right) Gen M = O ( M η ζ 1 ( R ) R S ( F ) + ζ 2 ( R ) M l o g ( 2/ δ ) ) and R S ( F ) R_S(\mathcal{F}) R S ( F ) is the (unnormalized) empirical Rademacher complexity of F \mathcal{F} F on M M M i.i.d. training tuples S S S .
Remark. Theorem 5 supports the observation of Saunshi et al. [46 ] that achieving a low contrastive loss alone may not guarantee good downstream performance, as exemplified by Proposition 3 . A low contrastive loss and a small internal discrepancy provide sufficient control of the incurred supervised risk. This theorem also highlights several insights: (i) The inductive biases of the function class and optimization algorithm should lead to the learned model exhibiting both a low contrastive loss L c o n ( f ^ ) L_{\mathrm{con}}(\hat{f}) L con ( f ^ ) and a small internal discrepancy Disc ( f ^ ) \operatorname{Disc}(\hat{f}) Disc ( f ^ ) . Given that Disc ( f ) ≤ Disc a ( f ) + Disc i ( f ) \operatorname{Disc}(f) \le\operatorname{Disc}_{a}(f) + \operatorname{Disc}_{i}(f) Disc ( f ) ≤ Disc a ( f ) + Disc i ( f ) , improving positive-pair alignment and reducing intra-class discrepancy tighten this upper bound. (ii) In alignment with classical learning theory principles, an adequately large number M M M of independent training tuples aids in reducing Gen M \operatorname{Gen}_{M} Gen M when the complexity term grows sublinearly in M M M . This perspective may help explain the empirical effectiveness of rich data augmentation in contrastive learning [4 , 24 ] .
The incurred supervised loss further controls the classification error of the linear classifier and its balanced error that weights all classes equally:
Corollary 6. Let h h h be the InfoNCE-incurred loss in Theorem 2 . For { c i } i = 1 k ∼ i . i . d . ρ T \{c_i\}_{i=1}^{k} \overset{\mathrm{i.i.d.}}{\sim} \rho_{\mathcal{T}} { c i } i = 1 k ∼ i.i.d. ρ T , write k c = ∑ i = 1 k I ( c i = c ) k_c = \sum_{i=1}^{k} \mathbb{I}(c_i = c) k c = ∑ i = 1 k I ( c i = c ) for c ∈ T c \in\mathcal{T} c ∈ T , and define h 0 ( y ) = E log ( 1 + k y ) h_0(y) = \mathbb{E}\log(1 + k_y) h 0 ( y ) = E log ( 1 + k y ) and ω k ( y ) = min c ≠ y E log ( 1 + k c 1 + k y ) \omega_k(y) = \min_{c \ne y} \mathbb{E}\log\left(1 + \frac{k_c}{1+k_y}\right) ω k ( y ) = min c = y E log ( 1 + 1 + k y k c ) for y ∈ T y \in\mathcal{T} y ∈ T . Then for any f f f and W W W , with any fixed rule for breaking ties, the prediction y ^ ( x ) = arg max c ∈ T w c T f ( x ) \hat{y}(x) = \arg\max_{c \in\mathcal{T}} w_c^{\mathsf{T}}f(x) y ^ ( x ) = arg max c ∈ T w c T f ( x ) satisfies
P ( x , y ) ∼ D T [ y ^ ( x ) ≠ y ] ≤ L s u p ( D T , W f , h ) − E y ∼ ρ T h 0 ( y ) min y ∈ T ω k ( y ) , (10) \mathbb{P}_{(x,y)\sim D_{\mathcal{T}}}[\hat{y}(x) \ne y] \le\frac{L_{\mathrm{sup}}(D_{\mathcal{T}}, Wf, h) - \mathbb{E}_{y\sim\rho_{\mathcal{T}}}h_0(y)}{\min_{y\in\mathcal{T}}\omega_k(y)}, \tag*{(10)} P ( x , y ) ∼ D T [ y ^ ( x ) = y ] ≤ min y ∈ T ω k ( y ) L sup ( D T , W f , h ) − E y ∼ ρ T h 0 ( y ) , (10)
1 ∣ T ∣ ∑ y ∈ T P x ∼ D y [ y ^ ( x ) ≠ y ] ≤ L s u p ( D T , W f , h ) − E y ∼ ρ T h 0 ( y ) ∣ T ∣ min y ∈ T ρ T ( y ) ω k ( y ) . \frac{1}{|\mathcal{T}|}\sum_{y\in\mathcal{T}}\mathbb{P}_{x\sim D_y}[\hat{y}(x) \ne y] \le\frac{L_{\mathrm{sup}}(D_{\mathcal{T}}, Wf, h) - \mathbb{E}_{y\sim\rho_{\mathcal{T}}}h_0(y)}{|\mathcal{T}|\min_{y\in\mathcal{T}}\rho_{\mathcal{T}}(y)\omega_k(y)}. ∣ T ∣ 1 y ∈ T ∑ P x ∼ D y [ y ^ ( x ) = y ] ≤ ∣ T ∣ min y ∈ T ρ T ( y ) ω k ( y ) L sup ( D T , W f , h ) − E y ∼ ρ T h 0 ( y ) .
With probability at least 1 − δ 1-\delta 1 − δ , Theorem 5 further bounds both numerators for the mean classifier of f ^ \hat{f} f ^ by L c o n ( f ) + R Disc ( f ^ ) + Gen M − E y ∼ ρ T h 0 ( y ) L_{\mathrm{con}}(f) + R\operatorname{Disc}(\hat{f}) + \operatorname{Gen}_{M} - \mathbb{E}_{y\sim\rho_{\mathcal{T}}}h_0(y) L con ( f ) + R Disc ( f ^ ) + Gen M − E y ∼ ρ T h 0 ( y ) for all f ∈ F f \in\mathcal{F} f ∈ F .
Extension to Supervised Contrastive Learning. In unsupervised contrastive learning, positive pairs usually consist of two randomly augmented views, whereas in supervised contrastive learning, positive pairs are drawn i.i.d. from the same class6 , embodying the principle of class-conditional independence between positive pairs (i.e., D p o s ( x , x + ∣ c ) = D c ( x ) D c ( x + ) \mathcal{D}_{\mathrm{pos}}(x,x^{+}\mid c) = \mathcal{D}^{c}(x)\mathcal{D}^{c}(x^{+}) D pos ( x , x + ∣ c ) = D c ( x ) D c ( x + ) , and Disc ( f ) = 0 \operatorname{Disc}(f)=0 Disc ( f ) = 0 ). Consequently, all results about random negative samples presented by Saunshi et al. [45 ] are relevant to the present setting.
In the supervised scenario, negative samples can instead be drawn from classes other than that of the anchor, that is, D n e g ( x − ∣ x ) = D ≠ y x ( x − ) \mathcal{D}_{\mathrm{neg}}(x^{-}\mid x) = \mathcal{D}^{\ne y_x}(x^{-}) D neg ( x − ∣ x ) = D = y x ( x − ) . Then supervised contrastive learning aims at minimizing
L c o n s u p ( f , D ; ℓ ) = E x , x + ∼ D p o s { x i − } i = 1 k ∼ i . i . d . D n e g ℓ ( f , x , x + , { x i − } i = 1 k ) = E c ∼ ρ T E x , x + ∼ i . i . d . D c { x i − } i = 1 k ∼ i . i . d . D ≠ c ℓ ( f , x , x + , { x i − } i = 1 k ) , (11) \begin{aligned}
L_{\mathrm{con}}^{\mathrm{sup}}(f,\mathcal{D};\ell) = \mathbb{E}_{x,x^{+}\sim\mathcal{D}_{\mathrm{pos}} \atop\{x_i^{-}\}_{i=1}^{k}\overset{\mathrm{i.i.d.}}{\sim}\mathcal{D}_{\mathrm{neg}}} \ell\left(f,x,x^{+},\{x_i^{-}\}_{i=1}^{k}\right) \\
&= \mathbb{E}_{c\sim\rho_{\mathcal{T}}}\mathbb{E}_{x,x^{+}\overset{\mathrm{i.i.d.}}{\sim}\mathcal{D}^{c} \atop\{x_i^{-}\}_{i=1}^{k}\overset{\mathrm{i.i.d.}}{\sim}\mathcal{D}^{\ne c}} \ell\left(f,x,x^{+},\{x_i^{-}\}_{i=1}^{k}\right), \tag*{(11)}
\end{aligned} L con sup ( f , D ; ℓ ) = E { x i − } i = 1 k ∼ i.i.d. D neg x , x + ∼ D pos ℓ ( f , x , x + , { x i − } i = 1 k ) = E c ∼ ρ T E { x i − } i = 1 k ∼ i.i.d. D = c x , x + ∼ i.i.d. D c ℓ ( f , x , x + , { x i − } i = 1 k ) , (11)
and its empirical counterpart is L ^ c o n s u p ( f ; ℓ ) \hat{L}_{\mathrm{con}}^{\mathrm{sup}}(f;\ell) L ^ con sup ( f ; ℓ ) . By an argument analogous to that of Theorem 5 , we obtain the following result:
Theorem 7. Under the loss conditions in Theorem 5, with probability at least 1 − δ 1-\delta 1 − δ , for all f ∈ F f \in\mathcal{F} f ∈ F , there exist a linear classifier W ∈ R ∣ T ∣ × d \mathbf{W} \in\mathbb{R}^{|\mathcal{T}|\times d} W ∈ R ∣ T ∣ × d and a supervised loss h : R ∣ T ∣ × T → R h : \mathbb{R}^{|\mathcal{T}|} \times\mathcal{T} \to\mathbb{R} h : R ∣ T ∣ × T → R such that
L s u p ( D T , W f ^ , h ) ≤ L ^ c o n s u p ( f , D ; ℓ ) + G e n M , (12) L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},\mathbf{W}\hat{f},h) \leq\hat{L}^{\mathrm{sup}}_{\mathrm{con}}(f,\mathcal{D};\ell)+\mathrm{Gen}_{M}, \tag*{(12)} L sup ( D T , W f ^ , h ) ≤ L ^ con sup ( f , D ; ℓ ) + Gen M , (12) where f ^ ∈ arg min f ∈ F L ^ c o n s u p ( f ; ℓ ) \hat{f} \in\arg\min_{f\in\mathcal{F}}\hat{L}^{\mathrm{sup}}_{\mathrm{con}}(f;\ell) f ^ ∈ arg min f ∈ F L ^ con sup ( f ; ℓ ) , and the incurred supervised loss is formulated as h = E { c i } i = 1 k ∼ i . i . d . ρ T ℓ ( f ( x ) , w y , { w c i } i = 1 k ) h = \mathbb{E}_{\{c_i\}_{i=1}^{k} \mathrel{\stackrel{\mathrm{i.i.d.}}{\sim}} \rho_{\mathcal{T}}}\ell(f(x),w_y,\{w_{c_i}\}_{i=1}^{k}) h = E { c i } i = 1 k ∼ i.i.d. ρ T ℓ ( f ( x ) , w y , { w c i } i = 1 k ) .
The Relaxed K-Means Loss on Representations
As mentioned above, Theorem 2 shows that the population supervised loss is bounded by the contrastive loss L c o n ( f ) L_{\mathrm{con}}(f) L con ( f ) and the internal discrepancy Disc ( f ) \operatorname{Disc}(f) Disc ( f ) . However, the generalization bound in Theorem 5 is limited by Disc ( f ^ ) \operatorname{Disc}(\hat{f}) Disc ( f ^ ) , which depends on the empirical risk minimizer f ^ \hat{f} f ^ . Since Disc ( f ) ≤ Disc a ( f ) + Disc i ( f ) \operatorname{Disc}(f) \leq\operatorname{Disc}_{a}(f) + \operatorname{Disc}_{i}(f) Disc ( f ) ≤ Disc a ( f ) + Disc i ( f ) and the positive-pair alignment Disc a ( f ) \operatorname{Disc}_{a}(f) Disc a ( f ) is already encouraged by contrastive learning [53 ] , we may also consider minimizing the empirical counterpart of the intra-class discrepancy Disc i ( f ) \operatorname{Disc}_{i}(f) Disc i ( f ) :
Disc ^ i ( f ) = 1 N ∑ n = 1 N ∥ f ( x n ) − μ ^ y x n ∥ , (13) \widehat{\operatorname{Disc}}_{i}(f) = \frac{1}{N}\sum_{n=1}^{N}\left\|f(x_n)-\hat{\mu}_{y_{x_n}}\right\|, \tag*{(13)} Disc i ( f ) = N 1 n = 1 ∑ N f ( x n ) − μ ^ y x n , (13)
where y x n y_{x_n} y x n denotes the label of sample x n x_n x n , μ ^ c = 1 N c ∑ n = 1 N f ( x n ) I ( y x n = c ) \hat{\mu}_c = \frac{1}{N_c}\sum_{n=1}^{N}f(x_n)\mathbb{I}(y_{x_n}=c) μ ^ c = N c 1 ∑ n = 1 N f ( x n ) I ( y x n = c ) , and N c N_c N c is the number of samples within class c c c .
Combining Theorem 2 with a uniform bound on the estimation error of Disc ^ i \widehat{\operatorname{Disc}}_{i} Disc i over F \mathcal{F} F , we can derive the following proposition:
Proposition 8. Under the notation and conditions in Theorem 5, with probability at least 1 − δ 1-\delta 1 − δ , any f ^ ∈ arg min f ∈ F L ^ c o n ( f ) + η ⋅ Disc ^ i ( f ) \hat{f}\in\arg\min_{f\in\mathcal{F}}\hat{L}_{\mathrm{con}}(f)+\eta\cdot\widehat{\operatorname{Disc}}_{i}(f) f ^ ∈ arg min f ∈ F L ^ con ( f ) + η ⋅ Disc i ( f ) satisfies
L s u p ( D T , W f ^ , h ) ≤ inf f ∈ F { L c o n ( f ) + η ⋅ Disc i ( f ) } + η ⋅ Disc a ( f ^ ) + G e n M + η ⋅ G e n N , L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},\mathbf{W}\hat{f},h)\leq\inf_{f\in\mathcal{F}}\{L_{\mathrm{con}}(f)+\eta\cdot\operatorname{Disc}_{i}(f)\}+\eta\cdot\operatorname{Disc}_{a}(\hat{f})+\mathrm{Gen}_{M}+\eta\cdot\mathrm{Gen}_{N}, L sup ( D T , W f ^ , h ) ≤ f ∈ F inf { L con ( f ) + η ⋅ Disc i ( f )} + η ⋅ Disc a ( f ^ ) + Gen M + η ⋅ Gen N , where h h h is the incurred supervised loss in Theorem 2, G e n N = O ( R S ′ ( F ) N + R d ∣ T ∣ + log ( 2 / δ ) N ) \mathrm{Gen}_{N}=O\left(\frac{R_{S'}(\mathcal{F})}{N}+R\sqrt{\frac{d|\mathcal{T}|+\log(2/\delta)}{N}}\right) Gen N = O ( N R S ′ ( F ) + R N d ∣ T ∣ + l o g ( 2/ δ ) ) , and R S ′ ( F ) R_{S'}(\mathcal{F}) R S ′ ( F ) is the (unnormalized) empirical Rademacher complexity of F \mathcal{F} F on S ′ = { x n } n = 1 N S'=\{x_n\}_{n=1}^{N} S ′ = { x n } n = 1 N .
The Relaxed K-Means Loss. Due to the absence of specific labels for calculating Disc ^ i ( f ) \widehat{\operatorname{Disc}}_{i}(f) Disc i ( f ) , we resort to using a surrogate. One intuitive approach is to employ k-means clustering to obtain C C C centroids { μ ^ c } c ∈ [ C ] \{\hat{\mu}_c\}_{c\in[C]} { μ ^ c } c ∈ [ C ] from the representations { f ( x i ) } i = 1 M \{f(x_i)\}_{i=1}^{M} { f ( x i ) } i = 1 M , followed by computing the minimal distance between each representation and these centroids, i.e., 1 M ∑ i = 1 M min c ∈ [ C ] ∥ f ( x i ) − μ ^ c ∥ \frac{1}{M}\sum_{i=1}^{M}\min_{c\in[C]}\|f(x_i)-\hat{\mu}_c\| M 1 ∑ i = 1 M min c ∈ [ C ] ∥ f ( x i ) − μ ^ c ∥ . However, this loss is not only inefficient but also requires a predetermined number of clusters. Moreover, the uniformity property of contrastive learning and stochastic batch training would make clustering challenging and potentially imprecise. To alleviate this issue, we consider reducing the distance between representations within a certain distance range. That is, we treat each representation as a center and reduce the distance from neighboring representations to it. This can be straightforwardly implemented with a truncation as follows:
L ^ k − m e a n s ( f ) = ∑ i , j min { ∥ f ( x i ) − f ( x j ) ∥ , τ } , (14) \widehat{L}_{\mathrm{k-means}}(f) = \sum_{i,j} \min\left\{ \lVert f(x_i) - f(x_j) \rVert, \tau\right\}, \tag*{(14)} L k − means ( f ) = i , j ∑ min { ∥ f ( x i ) − f ( x j )∥ , τ } , (14)
where τ > 0 \tau> 0 τ > 0 is a threshold to filter overly large pairwise distances. Although it requires no labels, the relaxed k-means loss controls the intra-class discrepancy as follows:
Proposition 9. Suppose that L ^ k − m e a n s ( f ) \widehat{L}_{\mathrm{k-means}}(f) L k − means ( f ) is computed on the sample { x n } n = 1 N \{x_n\}_{n=1}^{N} { x n } n = 1 N in Disc i ( f ) \operatorname{Disc}_i(f) Disc i ( f ) , i.e., i , j ∈ [ N ] i,j \in[N] i , j ∈ [ N ] in Equation (14) , and that τ ≤ 2 R \tau\leq2R τ ≤ 2 R . Write N min = min c ∈ T N c N_{\min} = \min_{c \in\mathcal{T}} N_c N m i n = min c ∈ T N c and N max = max c ∈ T N c N_{\max} = \max_{c \in\mathcal{T}} N_c N m a x = max c ∈ T N c . Then for all f ∈ F f \in\mathcal{F} f ∈ F ,
τ N min N 2 R Disc ^ i ( f ) ≤ L ^ k − m e a n s ( f ) ≤ 2 N max N Disc ^ i ( f ) + τ ( N 2 − ∑ c ∈ T N c 2 ) . (15) \frac{\tau N_{\min}N}{2R}\widehat{\operatorname{Disc}}_i(f) \leq\widehat{L}_{\mathrm{k-means}}(f) \leq2N_{\max}N\widehat{\operatorname{Disc}}_i(f) + \tau\left(N^2 - \sum_{c \in\mathcal{T}} N_c^2\right). \tag*{(15)} 2 R τ N m i n N Disc i ( f ) ≤ L k − means ( f ) ≤ 2 N m a x N Disc i ( f ) + τ ( N 2 − c ∈ T ∑ N c 2 ) . (15) If, in addition, ∥ f ( x i ) − f ( x j ) ∥ ≥ τ \lVert f(x_i) - f(x_j) \rVert\geq\tau ∥ f ( x i ) − f ( x j )∥ ≥ τ for all i , j ∈ [ N ] i,j \in[N] i , j ∈ [ N ] with y x i ≠ y x j y_{x_i} \ne y_{x_j} y x i = y x j , then
τ N min N 2 R Disc ^ i ( f ) ≤ L ^ k − m e a n s ( f ) − τ ( N 2 − ∑ c ∈ T N c 2 ) ≤ 2 N max N Disc ^ i ( f ) . (16) \frac{\tau N_{\min}N}{2R}\widehat{\operatorname{Disc}}_i(f) \leq\widehat{L}_{\mathrm{k-means}}(f) - \tau\left(N^2 - \sum_{c \in\mathcal{T}} N_c^2\right) \leq2N_{\max}N\widehat{\operatorname{Disc}}_i(f). \tag*{(16)} 2 R τ N m i n N Disc i ( f ) ≤ L k − means ( f ) − τ ( N 2 − c ∈ T ∑ N c 2 ) ≤ 2 N m a x N Disc i ( f ) . (16)
As shown in Figure 3 , the incorporation of relaxed k-means loss contributes to an improvement in linear probing, especially on the ImageNet-100 dataset (the complete experimental results can be found in Appendix § 10 .§ 2 ). This underscores the feasibility of minimizing the internal discrepancy in this manner. We hope that the relaxed k-means loss can stimulate new insights into unsupervised representation learning.
Figure 3. Linear probing accuracies (%) on CIFAR-10, CIFAR-100, and ImageNet-100 using unsupervised contrastive learning with the InfoNCE loss and the relaxed k-means loss, i.e., L ^ c o n + λ ⋅ L ^ k − m e a n s ( f ) \widehat{L}_{\mathrm{con}} + \lambda\cdot\widehat{L}_{\mathrm{k-means}}(f) L con + λ ⋅ L k − means ( f ) , where τ = 0.5 \tau= 0.5 τ = 0.5 .
On the Supervised Losses Incurred by Contrastive Learning
In Section 3.2, contrastive learning-incurred supervised losses are central to analyzing the downstream performance of contrastive learning. These losses entail an expectation over k k k i.i.d. class draws { c i } i = 1 k \{c_i\}_{i=1}^k { c i } i = 1 k and differ in form from typical classification losses. In this section, we investigate the behavior of the supervised losses incurred by contrastive learning, focusing specifically on InfoNCE and SpeCL.
Implications for Mitigating Class Imbalance
Real-world data often exhibits an imbalanced class distribution, primarily because some classes have an abundance of examples, while many others are associated with only a few. This class imbalance can make naive learning biased towards the majority classes, leading to poor performance and a narrow feature space for minority classes [43 ] . However, several studies have underlined the potential of contrastive learning to improve imbalanced learning. For instance, Kang et al. [27 ] observed that contrastive learning helps learn a balanced feature space, even in the presence of a highly skewed class distribution. Similarly, Li et al. (2022) argued that supervised contrastive learning can offer benefits to imbalanced learning. Nevertheless, neither study fully elucidates the underlying mechanisms driving the benefits of contrastive learning for imbalanced learning. In what follows, we theoretically demonstrate that contrastive learning implicitly mitigates class imbalance.
InfoNCE-Incurred Loss Approximates Balanced Softmax Loss. We demonstrate that the loss incurred by InfoNCE closely approximates the balanced softmax loss [43 ] , which accommodates class distribution shifts to mitigate class imbalance. The balanced softmax loss is expressed as h ~ = log E c ∼ ρ T e f ( x ) ⊤ ( w c − w y ) \tilde{h} = \log\mathbb{E}_{c\sim\rho_T} e^{f(x)^\top(w_c-w_y)} h ~ = log E c ∼ ρ T e f ( x ) ⊤ ( w c − w y ) , where we omit the term − log ρ T ( y ) -\log\rho_T(y) − log ρ T ( y ) that is independent of f f f and W W W . We also note that the InfoNCE-incurred loss h h h in Theorem 5 is defined as h ( x , y ) = E { c i } i = 1 k ∼ i . i . d . ρ T log [ 1 + ∑ i = 1 k e f ( x ) ⊤ ( w c i − w y ) ] h(x,y) = \mathbb{E}_{\{c_i\}_{i=1}^k \overset{\mathrm{i.i.d.}}{\sim} \rho_T} \log\left[1+\sum_{i=1}^k e^{f(x)^\top(w_{c_i}-w_y)}\right] h ( x , y ) = E { c i } i = 1 k ∼ i.i.d. ρ T log [ 1 + ∑ i = 1 k e f ( x ) ⊤ ( w c i − w y ) ] , which can be interpreted as an approximation of log [ 1 + k E c ∼ ρ T e f ( x ) ⊤ ( w c − w y ) ] \log\left[1+k\mathbb{E}_{c\sim\rho_T}e^{f(x)^\top(w_c-w_y)}\right] log [ 1 + k E c ∼ ρ T e f ( x ) ⊤ ( w c − w y ) ] that resembles h ~ \tilde{h} h ~ . Theoretically, we confirm that
Theorem 10. For the InfoNCE-incurred loss h h h and the balanced softmax loss h ~ \tilde{h} h ~ , we have
h = h ~ + log k + O ( k − 1 ) , h = \tilde{h} + \log k + O(k^{-1}), h = h ~ + log k + O ( k − 1 ) , and with probability at least 1 − δ 1-\delta 1 − δ , for all f ∈ F f \in\mathcal{F} f ∈ F ,
L s u p ( D T , W f ^ , h ~ ) + log k ≤ L c o n ( f ) + η ⋅ Disc ( f ^ ) + Gen M + O ( k − 1 ) . L_{\mathrm{sup}}(\mathcal{D}_{\mathrm{T}}, W\hat{f}, \tilde{h}) + \log k \leq L_{\mathrm{con}}(f) + \eta\cdot\operatorname{Disc}(\hat{f}) + \operatorname{Gen}_{M} + O(k^{-1}). L sup ( D T , W f ^ , h ~ ) + log k ≤ L con ( f ) + η ⋅ Disc ( f ^ ) + Gen M + O ( k − 1 ) .
The theorem above demonstrates that the loss incurred by InfoNCE approximates the balanced softmax loss, with an error term ∣ h − h ~ − log k ∣ |h - \tilde{h} - \log k| ∣ h − h ~ − log k ∣ that converges to zero at a rate of O ( k − 1 ) O(k^{-1}) O ( k − 1 ) . In other words, this approximation becomes progressively more accurate as the number of negatives k k k increases. As shown in Figure 4 and Table 2 , the performance of the InfoNCE-incurred loss usually improves for highly skewed class distributions (imbalance ratios of 50 and 100) as k k k increases, which suggests that contrastive learning with more negative samples can mitigate class imbalance.
Figure 4. Validation accuracies (%) on long-tailed CIFAR-10 and long-tailed CIFAR-100 datasets using supervised losses incurred by InfoNCE with different numbers of negatives and imbalance ratios { 10 , 20 , 50 , 100 } \{10, 20, 50, 100\} { 10 , 20 , 50 , 100 } , where the imbalance ratio denotes the sample size ratio between the largest and smallest classes.
Table 2. Validation accuracies (%) on long-tailed CIFAR-10 and long-tailed CIFAR-100 datasets. These results are obtained through supervised learning using cross entropy (CE), balanced softmax (BS), the InfoNCE-incurred loss (with the number of negatives k k k and the number of sampling repetitions t = 20 t = 20 t = 20 ), and the SpeCL-incurred (SpeCL-i) loss, where SpeCL-i† ^{\dagger} † denotes the results with normalized features and classifier weights. It is evident that the supervised loss incurred by InfoNCE outperforms CE, and SpeCL-i† ^{\dagger} † demonstrates superior performance compared to SpeCL-i. Furthermore, the performance of the InfoNCE-incurred loss generally improves as the number of negatives increases, particularly in scenarios with larger imbalance ratios.
Class Imbalance Only Scales Representations by SpeCL-Incurred Loss. For the SpeCL-incurred supervised loss h ( x , y ) = − 2 f ( x ) ⊤ w y + E c ∼ ρ T ( f ( x ) ⊤ w c ) 2 h(x,y) = -2f(x)^{\top}w_y + \mathbb{E}_{c\sim\rho_T}(f(x)^{\top}w_c)^2 h ( x , y ) = − 2 f ( x ) ⊤ w y + E c ∼ ρ T ( f ( x ) ⊤ w c ) 2 , we focus on the representations that minimize the population risk E ( x , y ) ∼ D T h ( x , y ) \mathbb{E}_{(x,y)\sim\mathcal{D}_T}h(x,y) E ( x , y ) ∼ D T h ( x , y ) . We demonstrate that an imbalanced class distribution only scales the norms of corresponding optimal representations and classifier weights by factors s ρ T ( c ) ∣ T ∣ \frac{s}{\sqrt{\rho_T(c)|\mathcal{T}|}} ρ T ( c ) ∣ T ∣ s and 1 s ρ T ( c ) ∣ T ∣ \frac{1}{s\sqrt{\rho_T(c)|\mathcal{T}|}} s ρ T ( c ) ∣ T ∣ 1 , respectively (see Appendix C.3), while preserving their angular geometry. To elucidate this, we prove that
Theorem 11. For the risk E ( x , y ) ∼ D T h ( x , y ) \mathbb{E}_{(x,y)\sim\mathcal{D}_T}h(x,y) E ( x , y ) ∼ D T h ( x , y ) , minimized over all representations and classifier weights without constraints, let f ~ ( x ) \tilde{f}(x) f ~ ( x ) and w ~ c \tilde{w}_c w ~ c jointly be a global minimizer under the condition that ρ T \rho_T ρ T is uniform. Then for any ρ T \rho_T ρ T and any constant s > 0 s>0 s > 0 , the representations f ^ ( x ) = s ρ T ( c ) ∣ T ∣ f ~ ( x ) \hat{f}(x)=\frac{s}{\sqrt{\rho_T(c)|\mathcal{T}|}}\tilde{f}(x) f ^ ( x ) = ρ T ( c ) ∣ T ∣ s f ~ ( x ) and classifier weights w ^ c = 1 s ρ T ( c ) ∣ T ∣ w ~ c \hat{w}_c=\frac{1}{s\sqrt{\rho_T(c)|\mathcal{T}|}}\tilde{w}_c w ^ c = s ρ T ( c ) ∣ T ∣ 1 w ~ c , defined for all x ∼ D c x\sim\mathcal{D}^c x ∼ D c and c ∈ T c\in\mathcal{T} c ∈ T , form a global minimizer of E ( x , y ) ∼ D T h ( x , y ) \mathbb{E}_{(x,y)\sim\mathcal{D}_T}h(x,y) E ( x , y ) ∼ D T h ( x , y ) , where we further have f ^ ( x ) ⊤ w ^ c = 1 ρ T ( c ) ∣ T ∣ f ~ ( x ) ⊤ w ~ c \hat{f}(x)^{\top}\hat{w}_c=\frac{1}{\rho_T(c)|\mathcal{T}|}\tilde{f}(x)^{\top}\tilde{w}_c f ^ ( x ) ⊤ w ^ c = ρ T ( c ) ∣ T ∣ 1 f ~ ( x ) ⊤ w ~ c for x ∼ D c x\sim\mathcal{D}^c x ∼ D c . Conversely, for any s > 0 s>0 s > 0 , every global minimizer under ρ T \rho_T ρ T arises in this way from a global minimizer under the uniform ρ T \rho_T ρ T .
Since the risk depends on f f f and W W W only through the logits f ( x ) ⊤ w c f(x)^{\top}w_c f ( x ) ⊤ w c , it is invariant under f ( x ) ↦ A f ( x ) f(x)\mapsto Af(x) f ( x ) ↦ A f ( x ) and w c ↦ A − ⊤ w c w_c\mapsto A^{-\top}w_c w c ↦ A − ⊤ w c for any invertible A ∈ R d × d A\in\mathbb{R}^{d\times d} A ∈ R d × d , so its global minimizers do not have a unique geometry. Normalizing features and classifier weights allows only orthogonal A A A , which preserve the geometry, and we further prove that
Proposition 12. For the risk E ( x , y ) ∼ D T h ( x , y ) \mathbb{E}_{(x,y)\sim\mathcal{D}_T}h(x,y) E ( x , y ) ∼ D T h ( x , y ) , minimized over all representations and classifier weights satisfying ∥ f ( x ) ∥ ≤ R \lVert f(x)\rVert\le R ∥ f ( x )∥ ≤ R and ∥ w c ∥ ≤ R \lVert w_c\rVert\le R ∥ w c ∥ ≤ R , assume that d ≥ ∣ T ∣ d\ge|\mathcal{T}| d ≥ ∣ T ∣ and R 2 ≤ 1 / max c ∈ T ρ T ( c ) R^2\le1/\max_{c\in\mathcal{T}}\rho_T(c) R 2 ≤ 1/ max c ∈ T ρ T ( c ) . Then f f f and { w c } c ∈ T \{w_c\}_{c\in\mathcal{T}} { w c } c ∈ T jointly form a global minimizer if and only if { w c / R } c ∈ T \{w_c/R\}_{c\in\mathcal{T}} { w c / R } c ∈ T is orthonormal and f ( x ) = w y x f(x)=w_yx f ( x ) = w y x almost surely, and the minimum is − 2 R 2 + R 4 ∑ c ∈ T ρ T 2 ( c ) -2R^2+R^4\sum_{c\in\mathcal{T}}\rho_T^2(c) − 2 R 2 + R 4 ∑ c ∈ T ρ T 2 ( c ) . The same holds under the normalization ∥ f ( x ) ∥ = ∥ w c ∥ = R \lVert f(x)\rVert=\lVert w_c\rVert=R ∥ f ( x )∥ = ∥ w c ∥ = R .
Remark. Theorem 11 suggests that cosine similarities between features or classifier weights optimally learned by SpeCL-incurred losses remain consistent regardless of the class distribution. Hence, after projection onto the unit sphere S d − 1 \mathbb{S}^{d-1} S d − 1 , the nonzero optimal features and classifier weights share the same geometry as their counterparts in the class-balanced case. Moreover, we can obtain a rebalanced feature space and make balanced decisions by simply normalizing features and classifier weights within SpeCL , as guaranteed by Proposition 12 and demonstrated in Table 2 .
The Optimality of Contrastive Learning-Incurred Losses
The optimal solutions of the CE loss, the MSE loss, and other losses usually exhibit neural collapse, an intriguing empirical phenomenon (Papan et al., 2020; Mixon et al., 2020; Fang et al., 2021; Han et al., 2022; Zhou et al., 2023; Wu and Mondelli, 2025), where specific manifestations in the classifier and last-layer representations are characterized. Graf et al. [12 ] ; Jiang et al. [25 ] also established neural collapse results in the empirical setting of supervised contrastive learning. Our objective here is to analyze the optimality of unsupervised or supervised contrastive learning by analyzing their incurred supervised losses.
Theorem 13. *For the class-balanced distribution and the InfoNCE-incurred supervised losses L s u p = E x ∼ D E { c i } i = 1 k ∼ i . i . d . ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) L_{\mathrm{sup}}=\mathbb{E}_{x\sim\mathcal{D}} \mathbb{E}_{\{c_i\}_{i=1}^k \overset{\mathrm{i.i.d.}}{\sim}\rho_T} \ell(f(x),\mu_{y_x},\{\mu_{c_i}\}_{i=1}^{k}) L sup = E x ∼ D E { c i } i = 1 k ∼ i.i.d. ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) in Theorem 2 and L s u p ′ = L'_{\mathrm{sup}}= L sup ′ =
E x ∼ D { c i } i = 1 k i . i . d . ∼ ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) \mathbb{E}_{x\sim\mathcal{D}_{\{c_i\}_{i=1}^{k}}^{\mathrm{i.i.d.}\sim\rho_{\mathcal{T}}}} \ell\left(f(x),\mu_{y_x},\{\mu_{c_i}\}_{i=1}^{k}\right) E x ∼ D { c i } i = 1 k i.i.d. ∼ ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k )
in Theorem 7 (where μ c = E x ∼ D c f ( x ) \mu_c=\mathbb{E}_{x\sim\mathcal{D}_c}f(x) μ c = E x ∼ D c f ( x ) for c ∈ T c\in\mathcal{T} c ∈ T ), if d ≥ ∣ T ∣ − 1 d\geq|\mathcal{T}|-1 d ≥ ∣ T ∣ − 1 , then f f f minimizes L s u p L_{\mathrm{sup}} L sup or L s u p ′ L'_{\mathrm{sup}} L sup ′ over all representations satisfying ∥ f ( x ) ∥ ≤ R \|f(x)\|\leq R ∥ f ( x ) ∥ ≤ R if and only if f ( x ) = μ y x f(x)=\mu_{y_x} f ( x ) = μ y x almost surely, where μ c ⊤ μ c ′ = − R 2 ∣ T ∣ − 1 \mu_c^{\top}\mu_{c'}=-\frac{R^2}{|\mathcal{T}|-1} μ c ⊤ μ c ′ = − ∣ T ∣ − 1 R 2 for c ≠ c ′ c\ne c' c = c ′ and ∥ μ c ∥ = R \|\mu_c\|=R ∥ μ c ∥ = R .
Theorem 13 shows that the InfoNCE-incurred loss possesses an optimal structure that aligns with the structures demonstrated for CE (Papyan et al., [40 ] ) and MSE (Zhou et al., [61 ] ). Specifically, these representations exhibit two critical properties of neural collapse (Papyan et al., [40 ] ): (i) variability collapse , where the representations equal their class means; (ii) a simplex equiangular tight frame (ETF) , wherein the class means have equal length, form equal-sized angles between any given pair, and attain the maximal minimum pairwise distance.
Corollary 14. Under the conditions of Theorem 13 , let μ ˉ = ∣ T ∣ − 1 ∑ c ∈ T μ c \bar{\mu}=|\mathcal{T}|^{-1}\sum_{c\in\mathcal{T}}\mu_c μ ˉ = ∣ T ∣ − 1 ∑ c ∈ T μ c , let G = ( μ c ⊤ μ c ′ ) c , c ′ ∈ T G=(\mu_c^{\top}\mu_{c'})_{c,c'\in\mathcal{T}} G = ( μ c ⊤ μ c ′ ) c , c ′ ∈ T be the Gram matrix of the class means, and let G E T F = ∣ T ∣ R 2 ∣ T ∣ − 1 ( I − 1 ∣ T ∣ 11 ⊤ ) G_{\mathrm{ETF}}=\frac{|\mathcal{T}|R^2}{|\mathcal{T}|-1}\left(I-\frac{1}{|\mathcal{T}|}\mathbf{1}\mathbf{1}^{\top}\right) G ETF = ∣ T ∣ − 1 ∣ T ∣ R 2 ( I − ∣ T ∣ 1 1 1 ⊤ ) be that of the simplex ETF in Theorem 13.
(i) If L s u p L_{\mathrm{sup}} L sup or L s u p ′ L'_{\mathrm{sup}} L sup ′ is within ϵ ≥ 0 \epsilon\geq0 ϵ ≥ 0 of its global minimum, then
1 ∣ T ∣ ∑ c ∈ T E x ∼ D c ∥ f ( x ) − μ c ∥ 2 + ∥ μ ˉ ∥ 2 ≤ 2 e 2 R 2 ϵ , \frac{1}{|\mathcal{T}|}\sum_{c\in\mathcal{T}}\mathbb{E}_{x\sim\mathcal{D}_c}\|f(x)-\mu_c\|^2+\|\bar{\mu}\|^2\leq2e^{2R^2}\epsilon, ∣ T ∣ 1 c ∈ T ∑ E x ∼ D c ∥ f ( x ) − μ c ∥ 2 + ∥ μ ˉ ∥ 2 ≤ 2 e 2 R 2 ϵ , 1 ∣ T ∣ 2 ∥ G − G E T F ∥ F 2 ≤ 8 e 4 R 2 ϵ . (17) \frac{1}{|\mathcal{T}|^2}\|G-G_{\mathrm{ETF}}\|_F^2\leq8e^{4R^2}\epsilon. \tag*{(17)} ∣ T ∣ 2 1 ∥ G − G ETF ∥ F 2 ≤ 8 e 4 R 2 ϵ . (17) (ii) For the empirical minimizer f ^ \hat{f} f ^ in Theorem 5, assume additionally that F \mathcal{F} F contains a class-constant simplex ETF of radius R R R and that P x , x + ∼ D p o s [ y x ≠ y x + ] ≤ α \mathbb{P}_{x,x^+\sim\mathcal{D}_{\mathrm{pos}}}[y_x\ne y_{x^+}]\leq\alpha P x , x + ∼ D pos [ y x = y x + ] ≤ α with x x x following the marginal distribution D \mathcal{D} D . Writing L s u p ( f ) L_{\mathrm{sup}}(f) L sup ( f ) for the unprimed mean-classifier risk in Theorem 13 and L s u p ∗ L^*_{\mathrm{sup}} L sup ∗ for its global minimum, with probability at least 1 − δ 1-\delta 1 − δ ,
L s u p ( f ^ ) − L s u p ∗ ≤ RDisc ( f ^ ) + Gen M + 2 ∣ T ∣ ∣ T ∣ − 1 R 2 α . (18) L_{\mathrm{sup}}(\hat{f})-L^*_{\mathrm{sup}}\leq\operatorname{RDisc}(\hat{f})+\operatorname{Gen}_{M}+\sqrt{\frac{2|\mathcal{T}|}{|\mathcal{T}|-1}}R^2\alpha. \tag*{(18)} L sup ( f ^ ) − L sup ∗ ≤ RDisc ( f ^ ) + Gen M + ∣ T ∣ − 1 2∣ T ∣ R 2 α . (18) (17) therefore holds for f = f ^ f=\hat{f} f = f ^ with ϵ \epsilon ϵ equal to this upper bound.
Corollary 14 extends Theorem 13 in two aspects: (i) any near-optimal representation approximately exhibits variability collapse with nearly centered class means, and the Gram matrix of its class means approximates that of a simplex ETF. (ii) by taking a class-constant simplex ETF in F \mathcal{F} F as the comparator in Theorem 5, we show that the empirical minimizer f ^ \hat{f} f ^ is near-optimal, with its excess risk controlled by the internal discrepancy Disc ( f ^ ) \operatorname{Disc}(\hat{f}) Disc ( f ^ ) , the generalization error Gen M \operatorname{Gen}_{M} Gen M , and the term 2 ∣ T ∣ ∣ T ∣ − 1 R 2 α \sqrt{\frac{2|\mathcal{T}|}{|\mathcal{T}|-1}}R^2\alpha ∣ T ∣ − 1 2∣ T ∣ R 2 α accounting for positive pairs from different classes. Consequently, the representations learned by InfoNCE approximately exhibit variability collapse and a simplex ETF when these terms are small.
The SpeCL-incurred loss also admits optimal representations exhibiting variability collapse. Its optimal class means minimize the error in a constrained approximation of the identity matrix I I I , which becomes a best rank-d d d approximation under the condition in (19) :
Theorem 15. For the SpeCL-incurred supervised loss L s u p = L_{\mathrm{sup}}= L sup = E ( x , y ) ∼ D T E { c i } i = 1 k ∼ ρ T i . i . d . ℓ ( f ( x ) , μ y , { μ c i } i = 1 k ) \mathbb{E}_{(x,y)\sim\mathcal{D}_{\mathcal{T}}}\mathbb{E}_{\{c_i\}_{i=1}^{k}\sim\rho_{\mathcal{T}}}^{\mathrm{i.i.d.}}\ell\left(f(x),\mu_y,\{\mu_{c_i}\}_{i=1}^{k}\right) E ( x , y ) ∼ D T E { c i } i = 1 k ∼ ρ T i.i.d. ℓ ( f ( x ) , μ y , { μ c i } i = 1 k ) in Theorem 2, where ℓ ( f ( x ) , μ y , { μ c i } i = 1 k ) = \ell\left(f(x),\mu_y,\{\mu_{c_i}\}_{i=1}^{k}\right)= ℓ ( f ( x ) , μ y , { μ c i } i = 1 k ) =
− 2 f ( x ) T μ y + 1 k ∑ i = 1 k ( f ( x ) T μ c i ) 2 -2f(x)^{\mathsf{T}}\mu_y+\frac{1}{k}\sum_{i=1}^{k}(f(x)^{\mathsf{T}}\mu_{c_i})^2 − 2 f ( x ) T μ y + k 1 ∑ i = 1 k ( f ( x ) T μ c i ) 2 , a global minimum is attained by a representation satisfying f ( x ) = μ c ∗ f(x)=\mu_c^* f ( x ) = μ c ∗ almost surely under D c D^c D c for all c ∈ T c\in\mathcal{T} c ∈ T , where H = [ ρ T ( c ) μ c ∗ ] c ∈ T H=[\sqrt{\rho_{\mathcal{T}}(c)}\mu_c^*]_{c\in\mathcal{T}} H = [ ρ T ( c ) μ c ∗ ] c ∈ T minimizes ∥ I − H T H ∥ F 2 \lVert I-H^{\mathsf{T}}H\rVert_F^2 ∥ I − H T H ∥ F 2 subject to ∥ μ c ∗ ∥ ≤ R \lVert\mu_c^*\rVert\le R ∥ μ c ∗ ∥ ≤ R . More specifically, writing r = min { d , ∣ T ∣ } r=\min\{d,|\mathcal{T}|\} r = min { d , ∣ T ∣ } , the minimum of L s u p L_{\mathrm{sup}} L sup equals − r -r − r if and only if
∑ c ∈ T min { 1 , R 2 ρ T ( c ) } ≥ r . (19) \sum_{c\in\mathcal{T}}\min\{1,R^2\rho_{\mathcal{T}}(c)\}\ge r. \tag*{(19)} c ∈ T ∑ min { 1 , R 2 ρ T ( c )} ≥ r . (19)
In this case, for every global minimizer f f f , the matrix H H H built from its class means μ c = E x ∼ D c f ( x ) \mu_c=\mathbb{E}_{x\sim D^c}f(x) μ c = E x ∼ D c f ( x ) satisfies that H T H H^{\mathsf{T}}H H T H is a rank-r r r orthogonal projection: H T H = I H^{\mathsf{T}}H=I H T H = I when ∣ T ∣ ≤ d |\mathcal{T}|\le d ∣ T ∣ ≤ d , and H T H H^{\mathsf{T}}H H T H is a best rank-d d d approximation of I I I when ∣ T ∣ > d |\mathcal{T}|>d ∣ T ∣ > d . For uniform ρ T \rho_{\mathcal{T}} ρ T , the minimum is
inf f L s u p = { − 2 R 2 + R 4 / r , R 2 ≤ r , − r , R 2 ≥ r . (20) \inf_f L_{\mathrm{sup}}=
\begin{cases}
-2R^2+R^4/r, & R^2\le r,\\
-r, & R^2\ge r.
\end{cases} \tag*{(20)} f inf L sup = { − 2 R 2 + R 4 / r , − r , R 2 ≤ r , R 2 ≥ r . (20)
When ∣ T ∣ ≤ d |\mathcal{T}|\le d ∣ T ∣ ≤ d , the condition in Equation (19) is equivalent to R 2 ≥ 1 / min c ∈ T ρ T ( c ) R^2\ge1/\min_{c\in\mathcal{T}}\rho_{\mathcal{T}}(c) R 2 ≥ 1/ min c ∈ T ρ T ( c ) . In this case, H T H = I H^{\mathsf{T}}H=I H T H = I means that the optimal class means are mutually orthogonal with ∥ μ c ∥ 2 = 1 / ρ T ( c ) \lVert\mu_c\rVert^2=1/\rho_{\mathcal{T}}(c) ∥ μ c ∥ 2 = 1/ ρ T ( c ) for any ρ T \rho_{\mathcal{T}} ρ T , which is the counterpart of Theorem 11 for the mean classifier: class imbalance only scales the optimal class means.
Conclusion
This paper introduces the novel concept of internal discrepancy as a unifying measure for various assumptions. This measure effectively captures the relationships between representations of positive pairs and latent clusters. By establishing an internal discrepancy-aware generalization bound, we provide a bridge for understanding contrastive learning without requiring additional assumptions, while also yielding practical strategies like the relaxed k k k -means loss. Furthermore, we delve into the behaviors of contrastive learning-incurred supervised losses. We show that under class imbalance, the InfoNCE-incurred loss approximates the balanced softmax loss, while features learned by the SpeCL-incurred loss maintain consistent cosine similarities regardless of class distributions. This helps explain why contrastive learning can mitigate class imbalance. The optimality of contrastive learning-incurred losses also involves some intriguing properties, including neural collapse properties for InfoNCE and the best approximation to the identity matrix for SpeCL. These results not only enhance our understanding of contrastive learning but also pave the way for exploring downstream behaviors.
Acknowledgments and Disclosure of Funding
This work is supported by National Natural Science Foundation of China under Grant 62525107.
Appendix: Internal Discrepancy for Contrastive Learning
Proofs of Theorems, Lemmas and Propositions
The Convexity and Lipschitzness of the InfoNCE Loss and Spectral Contrastive Loss
For fixed remaining representations, the InfoNCE loss is a log-sum-exp of affine functions, and the spectral contrastive loss is a linear function plus nonnegative quadratic terms. Thus both losses are separately convex in each representation. Their Lipschitz constants with respect to the positive representation can be taken as η = R \eta= R η = R and η = 2 R \eta= 2R η = 2 R , respectively, by differentiating with respect to that representation.
Lemma 16. The margin function ϕ : R ( k + 2 ) d → R k \phi: \mathbb{R}^{(k+2)d} \to\mathbb{R}^{k} ϕ : R ( k + 2 ) d → R k with ϕ ( v , v + , v 1 − , … , v k − ) = ( v T ( v + − v i − ) ) i ∈ [ k ] \phi(v,v^{+},v_{1}^{-},\ldots,v_{k}^{-}) = \left(v^{\mathsf{T}}(v^{+}-v_{i}^{-})\right)_{i\in[k]} ϕ ( v , v + , v 1 − , … , v k − ) = ( v T ( v + − v i − ) ) i ∈ [ k ] is 6 k R \sqrt{6k}R 6 k R -Lipschitz continuous when ∥ v ∥ 2 , ∥ v + ∥ 2 , ∥ v i − ∥ 2 ≤ R \lVert v\rVert_{2},\lVert v^{+}\rVert_{2},\lVert v_{i}^{-}\rVert_{2}\leq R ∥ v ∥ 2 , ∥ v + ∥ 2 , ∥ v i − ∥ 2 ≤ R .
Proof The nonzero blocks in row i i i of the Jacobian J J J are v + − v i − v^{+}-v_{i}^{-} v + − v i − , v v v , and − v -v − v , corresponding to v v v , v + v^{+} v + , and v i − v_{i}^{-} v i − . Hence
∥ J ∥ 2 2 ≤ ∥ J ∥ F 2 = ∑ i = 1 k ( ∥ v + − v i − ∥ 2 2 + 2 ∥ v ∥ 2 2 ) ≤ 6 k R 2 . \lVert J\rVert_{2}^{2}\leq\lVert J\rVert_{\mathrm{F}}^{2}=\sum_{i=1}^{k}\left(\lVert v^{+}-v_{i}^{-}\rVert_{2}^{2}+2\lVert v\rVert_{2}^{2}\right)\leq6kR^{2}. ∥ J ∥ 2 2 ≤ ∥ J ∥ F 2 = i = 1 ∑ k ( ∥ v + − v i − ∥ 2 2 + 2 ∥ v ∥ 2 2 ) ≤ 6 k R 2 . Integrating the Jacobian along line segments in the convex product of norm balls proves the claim.
Lemma 17. The spectral contrastive function ϕ : R ( k + 2 ) d → R k \phi: \mathbb{R}^{(k+2)d}\to\mathbb{R}^{k} ϕ : R ( k + 2 ) d → R k with ϕ ( v , v + , v 1 − , … , v k − ) = ( 2 v T v + − ( v T v i − ) 2 ) i ∈ [ k ] \phi(v,v^{+},v_{1}^{-},\ldots,v_{k}^{-})=\left(2v^{\mathsf{T}}v^{+}-(v^{\mathsf{T}}v_{i}^{-})^{2}\right)_{i\in[k]} ϕ ( v , v + , v 1 − , … , v k − ) = ( 2 v T v + − ( v T v i − ) 2 ) i ∈ [ k ] is 12 k R 2 + 12 k R 6 \sqrt{12kR^{2}+12kR^{6}} 12 k R 2 + 12 k R 6 -Lipschitz continuous when ∥ v ∥ 2 , ∥ v + ∥ 2 , ∥ v i − ∥ 2 ≤ R \lVert v\rVert_{2},\lVert v^{+}\rVert_{2},\lVert v_{i}^{-}\rVert_{2}\leq R ∥ v ∥ 2 , ∥ v + ∥ 2 , ∥ v i − ∥ 2 ≤ R .
Proof To show that ϕ \phi ϕ is Lipschitz continuous, we only need to prove that its Jacobian is bounded. Indeed, for all i ∈ [ k ] i\in[k] i ∈ [ k ] ,
∂ ϕ i ∂ v = 2 v + − 2 v i − ( v T v i − ) , ∂ ϕ i ∂ v + = 2 v , ∂ ϕ i ∂ v j − = − 2 v ( v T v j − ) I ( i = j ) . \frac{\partial\phi_i}{\partial v}=2v^{+}-2v_i^{-}(v^{\mathsf{T}}v_i^{-}),\qquad\frac{\partial\phi_i}{\partial v^{+}}=2v,\qquad\frac{\partial\phi_i}{\partial v_j^{-}}=-2v(v^{\mathsf{T}}v_j^{-})\mathbb{I}(i=j). ∂ v ∂ ϕ i = 2 v + − 2 v i − ( v T v i − ) , ∂ v + ∂ ϕ i = 2 v , ∂ v j − ∂ ϕ i = − 2 v ( v T v j − ) I ( i = j ) . The Frobenius norm of the Jacobian J J J therefore satisfies
∥ J ∥ F 2 = ∑ i = 1 k ( ∥ 2 v + − 2 v i − ( v T v i − ) ∥ 2 2 + 4 ∥ v ∥ 2 2 + 4 ∥ v ( v T v i − ) ∥ 2 2 ) \lVert J\rVert_{\mathrm{F}}^{2}=\sum_{i=1}^{k}\left(\lVert2v^{+}-2v_i^{-}(v^{\mathsf{T}}v_i^{-})\rVert_{2}^{2}+4\lVert v\rVert_{2}^{2}+4\lVert v(v^{\mathsf{T}}v_i^{-})\rVert_{2}^{2}\right) ∥ J ∥ F 2 = i = 1 ∑ k ( ∥ 2 v + − 2 v i − ( v T v i − ) ∥ 2 2 + 4 ∥ v ∥ 2 2 + 4 ∥ v ( v T v i − ) ∥ 2 2 ) ≤ 12 k R 2 + 12 k R 6 . \leq12kR^{2}+12kR^{6}. ≤ 12 k R 2 + 12 k R 6 . Since ∥ J ∥ 2 ≤ ∥ J ∥ F \lVert J\rVert_{2}\leq\lVert J\rVert_{\mathrm{F}} ∥ J ∥ 2 ≤ ∥ J ∥ F and the domain is convex, the stated Lipschitz bound follows.
Direct differentiation gives sharper tuple Lipschitz constants. For InfoNCE, write q i = e v T ( v i − − v + ) 1 + ∑ j e v T ( v j − − v + ) q_i=\frac{e^{v^{\mathsf{T}}(v_i^{-}-v^{+})}}{1+\sum_j e^{v^{\mathsf{T}}(v_j^{-}-v^{+})}} q i = 1 + ∑ j e v T ( v j − − v + ) e v T ( v i − − v + ) and s = ∑ i q i ≤ 1 s=\sum_i q_i\leq1 s = ∑ i q i ≤ 1 . Then
∇ v ℓ = ∑ i q i ( v i − − v + ) , ∇ v + ℓ = − s v , ∇ v i − ℓ = q i v , \nabla_v\ell=\sum_i q_i(v_i^{-}-v^{+}),\qquad\nabla_{v^{+}}\ell=-sv,\qquad\nabla_{v_i^{-}}\ell=q_iv, ∇ v ℓ = i ∑ q i ( v i − − v + ) , ∇ v + ℓ = − s v , ∇ v i − ℓ = q i v ,
so ∥ ∇ ℓ ∥ 2 ≤ R 2 ( 5 s 2 + ∑ i q i 2 ) ≤ 6 R 2 \lVert\nabla\ell\rVert^2 \le R^2(5s^2+\sum_i q_i^2) \le6R^2 ∥ ∇ ℓ ∥ 2 ≤ R 2 ( 5 s 2 + ∑ i q i 2 ) ≤ 6 R 2 and L ≤ 6 R L \le\sqrt{6}R L ≤ 6 R . Its values lie in [ log ( 1 + k e − 2 R 2 ) , log ( 1 + k e 2 R 2 ) ] [\log(1+ke^{-2R^2}),\log(1+ke^{2R^2})] [ log ( 1 + k e − 2 R 2 ) , log ( 1 + k e 2 R 2 )] , an interval of length at most 4 R 2 4R^2 4 R 2 . For SpeCL, differentiation gives
∇ v ℓ = − 2 v + + 2 k ∑ i ( v ⊤ v ˉ i ) v i − , ∇ v + ℓ = − 2 v , ∇ v i − ℓ = 2 k ( v ⊤ v ˉ i ) v , \nabla_v\ell=-2v^+ + \frac{2}{k}\sum_i(v^\top\bar v_i)v_i^-, \qquad\nabla_{v^+}\ell=-2v, \qquad\nabla_{v_i^-}\ell=\frac{2}{k}(v^\top\bar v_i)v, ∇ v ℓ = − 2 v + + k 2 i ∑ ( v ⊤ v ˉ i ) v i − , ∇ v + ℓ = − 2 v , ∇ v i − ℓ = k 2 ( v ⊤ v ˉ i ) v ,
and hence ∥ ∇ ℓ ∥ 2 ≤ 4 [ ( R + R 3 ) 2 + R 2 + R 6 / k ] ≤ 8 ( R + R 3 ) 2 \lVert\nabla\ell\rVert^2 \le4[(R+R^3)^2+R^2+R^6/k] \le8(R+R^3)^2 ∥ ∇ ℓ ∥ 2 ≤ 4 [( R + R 3 ) 2 + R 2 + R 6 / k ] ≤ 8 ( R + R 3 ) 2 . Thus L ≤ 2 2 R ( 1 + R 2 ) L \le2\sqrt{2}R(1+R^2) L ≤ 2 2 R ( 1 + R 2 ) , and its values lie in [ − 2 R 2 , 2 R 2 + R 4 ] [-2R^2,2R^2+R^4] [ − 2 R 2 , 2 R 2 + R 4 ] . The conditions of Theorem 5 hold with ( η , ζ 1 ( R ) , ζ 2 ( R ) ) = ( R , 6 , 4 R 2 ) (\eta,\zeta_1(R),\zeta_2(R))=(R,\sqrt{6},4R^2) ( η , ζ 1 ( R ) , ζ 2 ( R )) = ( R , 6 , 4 R 2 ) for InfoNCE and ( 2 R , 2 ( 1 + R 2 ) , 4 R 2 + R 4 ) (2R,\sqrt{2}(1+R^2),4R^2+R^4) ( 2 R , 2 ( 1 + R 2 ) , 4 R 2 + R 4 ) for SpeCL.
Generalization Bounds for Contrastive Learning
Proof of Theorem 2
Proof The key idea in the proof is the use of the Lipschitzness of the loss function ℓ \ell ℓ and Jensen’s inequality based on the convexity of ℓ \ell ℓ with respect to f ( x + ) f(x^+) f ( x + ) and f ( x i − ) f(x_i^-) f ( x i − ) . The unsupervised loss uses a random point from a class as a classifier; using the mean of the class as the classifier should only make the loss lower. Let μ c = E x ∼ D c f ( x ) \mu_c=\mathbb{E}_{x\sim D_c}f(x) μ c = E x ∼ D c f ( x ) be the mean representation of the class c ∈ T c\in\mathcal{T} c ∈ T and μ y x \mu_{y_x} μ y x denote the mean representation of the class of the sample x x x . Then we have
L c o n ( f , D ) = E ( x , x + ) ∼ D p o s E { x i − } i = 1 k ∼ i . i . d . D ℓ ( f ( x ) , f ( x + ) , { f ( x i − ) } i = 1 k ) = E x ∼ D E x + ∼ D p o s ( ⋅ ∣ x ) E { x i − } i = 1 k ∼ i . i . d . D ℓ ( f ( x ) , f ( x + ) , { f ( x i − ) } i = 1 k ) ≥ E x ∼ D E { x i − } i = 1 k ∼ i . i . d . D ℓ ( f ( x ) , E x + ∼ D p o s ( ⋅ ∣ x ) f ( x + ) , { f ( x i − ) } i = 1 k ) ≥ E x ∼ D E { c i } i = 1 k ∼ i . i . d . ρ T ℓ ( f ( x ) , μ y x + E x + ∼ D p o s ( ⋅ ∣ x ) f ( x + ) − μ y x , { μ c i } i = 1 k ) ≥ E x ∼ D E { c i } i = 1 k ∼ i . i . d . ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) − η ⋅ E x ∼ D ∥ E x + ∼ D p o s ( ⋅ ∣ x ) f ( x + ) − μ y x ∥ = E x ∼ D h ( μ y x T f ( x ) , { μ c T f ( x ) } c ≠ y x , c ∈ T ) − η ⋅ Disc ( f ) , \begin{aligned}
L_{\mathrm{con}}(f,\mathcal{D})
&=\mathbb{E}_{(x,x^+)\sim D_{\mathrm{pos}}}\mathbb{E}_{\{x_i^-\}_{i=1}^k\overset{\mathrm{i.i.d.}}{\sim}\mathcal{D}}\ell\left(f(x),f(x^+),\{f(x_i^-)\}_{i=1}^k\right)\\
&=\mathbb{E}_{x\sim\mathcal{D}}\mathbb{E}_{x^+\sim D_{\mathrm{pos}}(\cdot\mid x)}\mathbb{E}_{\{x_i^-\}_{i=1}^k\overset{\mathrm{i.i.d.}}{\sim}\mathcal{D}}\ell\left(f(x),f(x^+),\{f(x_i^-)\}_{i=1}^k\right)\\
&\ge\mathbb{E}_{x\sim\mathcal{D}}\mathbb{E}_{\{x_i^-\}_{i=1}^k\overset{\mathrm{i.i.d.}}{\sim}\mathcal{D}}\ell\left(f(x),\mathbb{E}_{x^+\sim D_{\mathrm{pos}}(\cdot\mid x)}f(x^+),\{f(x_i^-)\}_{i=1}^k\right)\\
&\ge\mathbb{E}_{x\sim\mathcal{D}}\mathbb{E}_{\{c_i\}_{i=1}^k\overset{\mathrm{i.i.d.}}{\sim}\rho_{\mathcal{T}}}\ell\left(f(x),\mu_{y_x}+\mathbb{E}_{x^+\sim D_{\mathrm{pos}}(\cdot\mid x)}f(x^+)-\mu_{y_x},\{\mu_{c_i}\}_{i=1}^k\right)\\
&\ge\mathbb{E}_{x\sim\mathcal{D}}\mathbb{E}_{\{c_i\}_{i=1}^k\overset{\mathrm{i.i.d.}}{\sim}\rho_{\mathcal{T}}}\ell\left(f(x),\mu_{y_x},\{\mu_{c_i}\}_{i=1}^k\right)\\
&\qquad-\eta\cdot\mathbb{E}_{x\sim\mathcal{D}}\left\|\mathbb{E}_{x^+\sim D_{\mathrm{pos}}(\cdot\mid x)}f(x^+)-\mu_{y_x}\right\|\\
&=\mathbb{E}_{x\sim\mathcal{D}}h\left(\mu_{y_x}^{\mathsf{T}}f(x),\{\mu_c^{\mathsf{T}}f(x)\}_{c\ne y_x,c\in\mathcal{T}}\right)-\eta\cdot\operatorname{Disc}(f),
\end{aligned} L con ( f , D ) = E ( x , x + ) ∼ D pos E { x i − } i = 1 k ∼ i.i.d. D ℓ ( f ( x ) , f ( x + ) , { f ( x i − ) } i = 1 k ) = E x ∼ D E x + ∼ D pos ( ⋅ ∣ x ) E { x i − } i = 1 k ∼ i.i.d. D ℓ ( f ( x ) , f ( x + ) , { f ( x i − ) } i = 1 k ) ≥ E x ∼ D E { x i − } i = 1 k ∼ i.i.d. D ℓ ( f ( x ) , E x + ∼ D pos ( ⋅ ∣ x ) f ( x + ) , { f ( x i − ) } i = 1 k ) ≥ E x ∼ D E { c i } i = 1 k ∼ i.i.d. ρ T ℓ ( f ( x ) , μ y x + E x + ∼ D pos ( ⋅ ∣ x ) f ( x + ) − μ y x , { μ c i } i = 1 k ) ≥ E x ∼ D E { c i } i = 1 k ∼ i.i.d. ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) − η ⋅ E x ∼ D E x + ∼ D pos ( ⋅ ∣ x ) f ( x + ) − μ y x = E x ∼ D h ( μ y x T f ( x ) , { μ c T f ( x ) } c = y x , c ∈ T ) − η ⋅ Disc ( f ) ,
where W = ( μ c ) c ∈ T T W=(\mu_c)_{c\in\mathcal{T}}^{\mathsf{T}} W = ( μ c ) c ∈ T T and h ( μ y x T f ( x ) , { μ c T f ( x ) } c ≠ y x , c ∈ T ) = E { c i } i = 1 k ∼ i . i . d . ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) h\left(\mu_{y_x}^{\mathsf{T}}f(x),\{\mu_c^{\mathsf{T}}f(x)\}_{c\ne y_x,c\in\mathcal{T}}\right)=\mathbb{E}_{\{c_i\}_{i=1}^k\overset{\mathrm{i.i.d.}}{\sim}\rho_{\mathcal{T}}}\ell\left(f(x),\mu_{y_x},\{\mu_{c_i}\}_{i=1}^k\right) h ( μ y x T f ( x ) , { μ c T f ( x ) } c = y x , c ∈ T ) = E { c i } i = 1 k ∼ i.i.d. ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) . The first and second inequalities follow by applying Jensen’s inequality and the convexity of ℓ \ell ℓ with respect to f ( x + ) f(x^+) f ( x + ) and f ( x i − ) f(x_i^-) f ( x i − ) , and the third inequality follows from the Lipschitzness of ℓ \ell ℓ . Under the stated class-constant condition, Disc ( f ) = 0 \operatorname{Disc}(f)=0 Disc ( f ) = 0 and all three inequalities are equalities.
Proof of Proposition 3
Proof For any f ′ f' f ′ satisfying ∥ f ′ ( x ) ∥ ≤ R \lVert f'(x)\rVert\le R ∥ f ′ ( x )∥ ≤ R , let μ ˉ ′ = E x ∼ D f ′ ( x ) \bar{\mu}'=\mathbb{E}_{x\sim\mathcal{D}}f'(x) μ ˉ ′ = E x ∼ D f ′ ( x ) . Since x + = x x^+=x x + = x , the InfoNCE loss is log [ 1 + ∑ i = 1 k e z i ] \log[1+\sum_{i=1}^k e^{z_i}] log [ 1 + ∑ i = 1 k e z i ] with z i = f ′ ( x ) T f ′ ( x i − ) − ∥ f ′ ( x ) ∥ 2 z_i=f'(x)^{\mathsf{T}}f'(x_i^-)-\lVert f'(x)\rVert^2 z i = f ′ ( x ) T f ′ ( x i − ) − ∥ f ′ ( x ) ∥ 2 , which is convex in ( z 1 , … , z k ) (z_1,\ldots,z_k) ( z 1 , … , z k ) . Applying Jensen’s inequality to the negatives and then to the anchor gives
L c o n ( f ′ ) ≥ E x ∼ D log [ 1 + k e f ′ ( x ) T μ ˉ ′ − ∥ f ′ ( x ) ∥ 2 ] ≥ log [ 1 + k e ∥ μ ˉ ′ ∥ 2 − E x ∼ D ∥ f ′ ( x ) ∥ 2 ] ≥ log ( 1 + k e − R 2 ) . L_{\mathrm{con}}(f') \ge\mathbb{E}_{x\sim\mathcal{D}}\log\left[1+ke^{f'(x)^{\mathsf{T}}\bar{\mu}'-\lVert f'(x)\rVert^2}\right]
\ge\log\left[1+ke^{\lVert\bar{\mu}'\rVert^2-\mathbb{E}_{x\sim\mathcal{D}}\lVert f'(x)\rVert^2}\right]\ge\log\left(1+ke^{-R^2}\right). L con ( f ′ ) ≥ E x ∼ D log [ 1 + k e f ′ ( x ) T μ ˉ ′ − ∥ f ′ ( x ) ∥ 2 ] ≥ log [ 1 + k e ∥ μ ˉ ′ ∥ 2 − E x ∼ D ∥ f ′ ( x ) ∥ 2 ] ≥ log ( 1 + k e − R 2 ) .
Let m = ⌈ k / ( 2 ϵ ) ⌉ m=\lceil k/(2\epsilon)\rceil m = ⌈ k / ( 2 ϵ )⌉ , and let { u c , i } c ∈ T , i ∈ [ m ] \{u_{c,i}\}_{c\in\mathcal{T},i\in[m]} { u c , i } c ∈ T , i ∈ [ m ] be orthonormal vectors in R d \mathbb{R}^d R d , which exist since d ≥ m ∣ T ∣ d\ge m|\mathcal{T}| d ≥ m ∣ T ∣ . Let D \mathcal{D} D assign probability ρ T ( c ) / ( 2 m ) \rho_{\mathcal{T}}(c)/(2m) ρ T ( c ) / ( 2 m ) to each of 2 m 2m 2 m distinct points x c , i x_{c,i} x c , i and x c , i ′ x'_{c,i} x c , i ′ , i ∈ [ m ] i\in[m] i ∈ [ m ] , of class c c c , and set f ( x c , i ) = R u c , i f(x_{c,i})=Ru_{c,i} f ( x c , i ) = R u c , i and f ( x c , i ′ ) = − R u c , i f(x'_{c,i})=-Ru_{c,i} f ( x c , i ′ ) = − R u c , i . Then E x ∼ D c f ( x ) = 0 \mathbb{E}_{x\sim\mathcal{D}_c}f(x)=0 E x ∼ D c f ( x ) = 0 for every c ∈ T c\in\mathcal{T} c ∈ T , so the mean classifier is W = 0 W=0 W = 0 and L s u p ( D T , W f , h ) = log ( 1 + k ) L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},Wf,h)=\log(1+k) L sup ( D T , W f , h ) = log ( 1 + k ) . Moreover, x + = x x^+=x x + = x and ∥ f ( x ) ∥ = R \lVert f(x)\rVert=R ∥ f ( x )∥ = R give Disc ( f ) = R \operatorname{Disc}(f)=R Disc ( f ) = R . For an anchor x x x and z i z_i z i defined by f f f , we have z i = 0 z_i=0 z i = 0 if x i − = x x_i^-=x x i − = x and z i ≤ − R 2 z_i\le-R^2 z i ≤ − R 2 otherwise. Letting J J J be the number of negatives equal to x x x , we obtain
log [ 1 + ∑ i = 1 k e z i ] ≤ log [ 1 + J + ( k − J ) e − R 2 ] ≤ log ( 1 + k e − R 2 ) + J . \log\left[1+\sum_{i=1}^{k}e^{z_i}\right]\le\log\left[1+J+(k-J)e^{-R^2}\right]\le\log\left(1+ke^{-R^2}\right)+J. log [ 1 + i = 1 ∑ k e z i ] ≤ log [ 1 + J + ( k − J ) e − R 2 ] ≤ log ( 1 + k e − R 2 ) + J .
Since E J = k ρ T ( y x ) / ( 2 m ) ≤ ϵ \mathbb{E}J=k\rho_{\mathcal{T}}(y_x)/(2m)\le\epsilon E J = k ρ T ( y x ) / ( 2 m ) ≤ ϵ , we have L c o n ( f ) ≤ log ( 1 + k e − R 2 ) + ϵ ≤ inf f ′ L c o n ( f ′ ) + ϵ L_{\mathrm{con}}(f)\le\log(1+ke^{-R^2})+\epsilon\le\inf_{f'}L_{\mathrm{con}}(f')+\epsilon L con ( f ) ≤ log ( 1 + k e − R 2 ) + ϵ ≤ inf f ′ L con ( f ′ ) + ϵ . Finally, L c o n ( f ) + η ⋅ Disc ( f ) ≤ log ( 1 + k e − R 2 ) + R 2 + ϵ = log ( e R 2 + k ) + ϵ L_{\mathrm{con}}(f)+\eta\cdot\operatorname{Disc}(f)\le\log(1+ke^{-R^2})+R^2+\epsilon=\log(e^{R^2}+k)+\epsilon L con ( f ) + η ⋅ Disc ( f ) ≤ log ( 1 + k e − R 2 ) + R 2 + ϵ = log ( e R 2 + k ) + ϵ , which rearranges to the stated inequality.
Proof of Lemma 4
Proof Write C = ∣ T ∣ C=|\mathcal{T}| C = ∣ T ∣ , μ c = E x ∼ D c f ( x ) \mu_c=\mathbb{E}_{x\sim\mathcal{D}_c}f(x) μ c = E x ∼ D c f ( x ) , μ ˉ = C − 1 ∑ c μ c \bar{\mu}=C^{-1}\sum_c\mu_c μ ˉ = C − 1 ∑ c μ c , and Δ = C − 1 ∑ c ∥ μ c ∥ 2 − ∥ μ ˉ ∥ 2 ≤ R 2 \Delta=C^{-1}\sum_c\lVert\mu_c\rVert^2-\lVert\bar{\mu}\rVert^2\le R^2 Δ = C − 1 ∑ c ∥ μ c ∥ 2 − ∥ μ ˉ ∥ 2 ≤ R 2 . Define
Φ ( z ) = ∑ j = 0 k ( k j ) C − j ( 1 − C − 1 ) k − j log [ 1 + j + ( k − j ) e z ] . \Phi(z)=\sum_{j=0}^{k}\binom{k}{j}C^{-j}(1-C^{-1})^{k-j}\log[1+j+(k-j)e^z]. Φ ( z ) = j = 0 ∑ k ( j k ) C − j ( 1 − C − 1 ) k − j log [ 1 + j + ( k − j ) e z ] .
Conditioning on the number of negative classes equal to the target class, and applying Jensen’s inequality to the other negative classes, the anchor, and the target class, gives
H ( f ) ≥ Φ ( − C Δ C − 1 ) ≥ Φ ( − C R 2 C − 1 ) . \mathcal{H}(f)\ge\Phi\left(-\frac{C\Delta}{C-1}\right)\ge\Phi\left(-\frac{CR^2}{C-1}\right). H ( f ) ≥ Φ ( − C − 1 C Δ ) ≥ Φ ( − C − 1 C R 2 ) .
Every class-constant representation whose class means form a simplex ETF of radius R R R attains this bound, and such representations exist since their Gram matrix C R 2 C − 1 ( I − 1 C 11 T ) \frac{CR^2}{C-1}(I-\frac{1}{C}\mathbf{1}\mathbf{1}^{\mathsf{T}}) C − 1 C R 2 ( I − C 1 1 1 T ) is positive semidefinite of rank C − 1 ≤ d C-1\le d C − 1 ≤ d . Since Φ \Phi Φ is strictly increasing, every global minimizer has Δ = R 2 \Delta=R^2 Δ = R 2 , hence μ ˉ = 0 \bar{\mu}=0 μ ˉ = 0 and ∥ μ c ∥ = R \lVert\mu_c\rVert=R ∥ μ c ∥ = R for every c c c . Moreover, E x ∼ D c ∥ f ( x ) − μ c ∥ 2 = E x ∼ D c ∥ f ( x ) ∥ 2 − ∥ μ c ∥ 2 ≤ R 2 − ∥ μ c ∥ 2 = 0 \mathbb{E}_{x\sim\mathcal{D}_c}\lVert f(x)-\mu_c\rVert^2=\mathbb{E}_{x\sim\mathcal{D}_c}\lVert f(x)\rVert^2-\lVert\mu_c\rVert^2\le R^2-\lVert\mu_c\rVert^2=0 E x ∼ D c ∥ f ( x ) − μ c ∥ 2 = E x ∼ D c ∥ f ( x ) ∥ 2 − ∥ μ c ∥ 2 ≤ R 2 − ∥ μ c ∥ 2 = 0 , so f ( x ) = μ c f(x)=\mu_c f ( x ) = μ c almost surely. The event with exactly k − 1 k-1 k − 1 negatives in the target class has positive probability. Equality in its strictly convex scalar Jensen step implies that μ c T μ c ′ \mu_c^{\mathsf{T}}\mu_{c'} μ c T μ c ′ is constant over c ′ ≠ c c'\ne c c ′ = c . As μ ˉ = 0 \bar{\mu}=0 μ ˉ = 0 , this constant is − R 2 / ( C − 1 ) -R^2/(C-1) − R 2 / ( C − 1 ) . Hence f f f minimizes H ( f ) \mathcal{H}(f) H ( f ) if and only if f ( x ) = μ y x f(x)=\mu_{y_x} f ( x ) = μ y x almost surely, where ∥ μ c ∥ = R \lVert\mu_c\rVert=R ∥ μ c ∥ = R and μ c T μ c ′ = − R 2 / ( C − 1 ) \mu_c^{\mathsf{T}}\mu_{c'}=-R^2/(C-1) μ c T μ c ′ = − R 2 / ( C − 1 ) for c ≠ c ′ c\ne c' c = c ′ . Applying Jensen’s inequality in the same way to the CE risk gives
E ( x , y ) ∼ D T log [ 1 + ∑ c ≠ y e f ( x ) T ( μ c − μ y ) ] ≥ log [ 1 + ( C − 1 ) e − C Δ / ( C − 1 ) ] ≥ log [ 1 + ( C − 1 ) e − C R 2 / ( C − 1 ) ] . \mathbb{E}_{(x,y)\sim D_{\mathcal{T}}}\log\left[1+\sum_{c\ne y}e^{f(x)^{\mathsf{T}}(\mu_c-\mu_y)}\right]
\ge\log\left[1+(C-1)e^{-C\Delta/(C-1)}\right]\ge\log\left[1+(C-1)e^{-CR^2/(C-1)}\right]. E ( x , y ) ∼ D T log 1 + c = y ∑ e f ( x ) T ( μ c − μ y ) ≥ log [ 1 + ( C − 1 ) e − C Δ/ ( C − 1 ) ] ≥ log [ 1 + ( C − 1 ) e − C R 2 / ( C − 1 ) ] .
Every minimizer characterized above attains this bound over the same mean-classifier representations. Conversely, equality in this chain requires Δ = R 2 \Delta=R^2 Δ = R 2 , which again implies μ ˉ = 0 \bar{\mu}=0 μ ˉ = 0 , ∥ μ c ∥ = R \lVert\mu_c\rVert=R ∥ μ c ∥ = R , and f ( x ) = μ c f(x)=\mu_c f ( x ) = μ c almost surely. Equality in the strictly convex Jensen step over c ≠ y c\ne y c = y then implies that μ y T μ c \mu_y^{\mathsf{T}}\mu_c μ y T μ c is constant over c ≠ y c\ne y c = y , so every minimizer of the CE risk is also a minimizer of H ( f ) \mathcal{H}(f) H ( f ) , completing the proof.
Proof of Theorem 5
Proof Let w c = E x ∼ D c f ^ ( x ) w_c=\mathbb{E}_{x\sim D_c}\hat{f}(x) w c = E x ∼ D c f ^ ( x ) and let W W W have rows w c T w_c^{\mathsf{T}} w c T . Then L s u p ( D T , W f ^ , h ) = E x ∼ D h ( w y T f ^ ( x ) , { w c T f ^ ( x ) } c ≠ y , x , c ∈ T ) L_{\mathrm{sup}}(D_{\mathcal{T}},W\hat{f},h)=\mathbb{E}_{x\sim D}h(w_y^{\mathsf{T}}\hat{f}(x),\{w_c^{\mathsf{T}}\hat{f}(x)\}_{c\ne y,x,c\in\mathcal{T}}) L sup ( D T , W f ^ , h ) = E x ∼ D h ( w y T f ^ ( x ) , { w c T f ^ ( x ) } c = y , x , c ∈ T ) . According to Theorem 2 , we have
L s u p ( D T , W f ^ , h ) ≤ L c o n ( f ^ ) + η ⋅ Disc ( f ^ ) . L_{\mathrm{sup}}(D_{\mathcal{T}},W\hat{f},h)\le L_{\mathrm{con}}(\hat{f})+\eta\cdot\operatorname{Disc}(\hat{f}). L sup ( D T , W f ^ , h ) ≤ L con ( f ^ ) + η ⋅ Disc ( f ^ ) .
We further apply Theorem 19 . Then, with probability at least 1 − δ 1-\delta 1 − δ , for all f ∈ F f\in\mathcal{F} f ∈ F ,
L s u p ( D T , W f ^ , h ) ≤ L c o n ( f ) + η ⋅ Disc ( f ^ ) + O ( η ζ 1 ( R ) R S ( F ) M + ζ 2 ( R ) log ( 2 / δ ) M ) . L_{\mathrm{sup}}(D_{\mathcal{T}},W\hat{f},h)\le L_{\mathrm{con}}(f)+\eta\cdot\operatorname{Disc}(\hat{f})+O\left(\frac{\eta\zeta_1(R)\mathcal{R}_S(\mathcal{F})}{M}+\zeta_2(R)\sqrt{\frac{\log(2/\delta)}{M}}\right). L sup ( D T , W f ^ , h ) ≤ L con ( f ) + η ⋅ Disc ( f ^ ) + O ( M η ζ 1 ( R ) R S ( F ) + ζ 2 ( R ) M log ( 2/ δ ) ) .
which finishes the proof.
The vector-contraction inequality is as follows:
Lemma 18 [35 ] . Let Z Z Z be any set and S = { z j } j = 1 M ∈ Z M \mathcal{S}=\{z_j\}_{j=1}^{M}\in Z^M S = { z j } j = 1 M ∈ Z M . Let F ~ \widetilde{\mathcal{F}} F be a class of functions f ~ : Z → R n \tilde{f}:Z\to\mathbb{R}^n f ~ : Z → R n and h : R n → R h:\mathbb{R}^n\to\mathbb{R} h : R n → R be L L L -Lipschitz. For all f ~ ∈ F ~ \tilde{f}\in\widetilde{\mathcal{F}} f ~ ∈ F , let g f ~ = h ∘ f ~ g_{\tilde{f}}=h\circ\tilde{f} g f ~ = h ∘ f ~ . Then
E σ ∼ { ± 1 } M [ sup f ~ ∈ F ~ ⟨ σ , ( g f ~ ) ∣ S ⟩ ] ≤ 2 L E σ ∼ { ± 1 } n M [ sup f ~ ∈ F ~ ⟨ σ , f ~ ∣ S ⟩ ] . (21) \mathbb{E}_{\sigma\sim\{\pm1\}^{M}}\left[\sup_{\tilde{f}\in\widetilde{\mathcal{F}}}\left\langle\sigma,(g_{\tilde{f}})|_{\mathcal{S}}\right\rangle\right]\le\sqrt{2}L\mathbb{E}_{\sigma\sim\{\pm1\}^{nM}}\left[\sup_{\tilde{f}\in\widetilde{\mathcal{F}}}\left\langle\sigma,\tilde{f}|_{\mathcal{S}}\right\rangle\right]. \tag*{(21)} E σ ∼ { ± 1 } M [ f ~ ∈ F sup ⟨ σ , ( g f ~ ) ∣ S ⟩ ] ≤ 2 L E σ ∼ { ± 1 } n M [ f ~ ∈ F sup ⟨ σ , f ~ ∣ S ⟩ ] . (21) where f ~ ∣ S = ( f ~ t ( z j ) ) t ∈ [ n ] , j ∈ [ M ] \tilde{f}|_{\mathcal{S}}=\left(\tilde{f}_t(z_j)\right)_{t\in[n],j\in[M]} f ~ ∣ S = ( f ~ t ( z j ) ) t ∈ [ n ] , j ∈ [ M ] and all signs are independent Rademacher variables.
Proof Apply Corollary 4 of Maurer [35 ] to the finite-sample restrictions { f ~ ∣ S : f ~ ∈ F ~ } \{\tilde{f}|_{\mathcal{S}}:\tilde{f}\in\widetilde{\mathcal{F}}\} { f ~ ∣ S : f ~ ∈ F } with the Euclidean Lipschitz constant L L L . The independent coordinate signs in that corollary give exactly the right-hand side. If h h h is only defined on the relevant representation domain, a scalar L L L -Lipschitz extension to R n \mathbb{R}^n R n gives the same values on those restrictions.
Theorem 19. Let the loss on representation tuples be L L L -Lipschitz with respect to the Euclidean norm and take values in [ a , a + B ] [a, a+B] [ a , a + B ] for some B > 0 B>0 B > 0 on the domain where each representation has norm at most R R R . For δ ∈ ( 0 , 1 ) \delta\in(0,1) δ ∈ ( 0 , 1 ) , with probability at least 1 − δ 1-\delta 1 − δ over M M M i.i.d. training tuples S = { ( x j , x j + , x j 1 − , … , x j k − ) } j = 1 M S=\{(x_j,x_j^+,x_{j1}^-,\ldots,x_{jk}^-)\}_{j=1}^M S = {( x j , x j + , x j 1 − , … , x j k − ) } j = 1 M , the empirical minimizer f ^ \hat{f} f ^ satisfies, for all f ∈ F f\in\mathcal{F} f ∈ F ,
L c o n ( f ^ ) ≤ L c o n ( f ) + O ( L R S ( F ) M + B log ( 2 / δ ) M ) . (22) L_{\mathrm{con}}(\hat{f})\leq L_{\mathrm{con}}(f)+O\left(\frac{L\mathcal{R}_S(\mathcal{F})}{M}+B\sqrt{\frac{\log(2/\delta)}{M}}\right). \tag*{(22)} L con ( f ^ ) ≤ L con ( f ) + O ( M L R S ( F ) + B M log ( 2/ δ ) ) . (22) where
R S ( F ) = E σ ∼ { ± 1 } ( k + 2 ) d M [ sup f ∈ F ⟨ σ , f ∣ S ⟩ ] and f ∣ S = ( f t ( x j ) , f t ( x j + ) , f t ( x j 1 − ) , … , f t ( x j k − ) ) j ∈ [ M ] , t ∈ [ d ] . \mathcal{R}_S(\mathcal{F})=\mathbb{E}_{\sigma\sim\{\pm1\}^{(k+2)dM}}\left[\sup_{f\in\mathcal{F}}\langle\sigma,f|_S\rangle\right]\quad\text{and}\quad f|_S=\left(f_t(x_j),f_t(x_j^+),f_t(x_{j1}^-),\ldots,f_t(x_{jk}^-)\right)_{j\in[M],t\in[d]}. R S ( F ) = E σ ∼ { ± 1 } ( k + 2 ) d M [ f ∈ F sup ⟨ σ , f ∣ S ⟩ ] and f ∣ S = ( f t ( x j ) , f t ( x j + ) , f t ( x j 1 − ) , … , f t ( x j k − ) ) j ∈ [ M ] , t ∈ [ d ] .
Proof. First, we use the classical empirical Rademacher bound. For a class G \mathcal{G} G of functions from Z \mathcal{Z} Z to [ 0 , 1 ] [0,1] [ 0 , 1 ] and an i.i.d. sample S = { z j } j = 1 M S=\{z_j\}_{j=1}^M S = { z j } j = 1 M , with probability at least 1 − δ / 2 1-\delta/2 1 − δ /2 , for all g ∈ G g\in\mathcal{G} g ∈ G ,
E [ g ( z ) ] ≤ 1 M ∑ j = 1 M g ( z j ) + 2 R S ( G ) M + 3 log ( 4 / δ ) 2 M . \mathbb{E}[g(z)]\leq\frac{1}{M}\sum_{j=1}^{M}g(z_j)+\frac{2\mathcal{R}_S(\mathcal{G})}{M}+3\sqrt{\frac{\log(4/\delta)}{2M}}. E [ g ( z )] ≤ M 1 j = 1 ∑ M g ( z j ) + M 2 R S ( G ) + 3 2 M log ( 4/ δ ) .
Here R S ( G ) \mathcal{R}_S(\mathcal{G}) R S ( G ) is unnormalized. Apply this bound with Z = X k + 2 \mathcal{Z}=\mathcal{X}^{k+2} Z = X k + 2 and
G = { g f ( z ) = ℓ ( f , x , x + , { x i − } i = 1 k ) − a B : f ∈ F } . \mathcal{G}=\left\{g_f(z)=\frac{\ell(f,x,x^+,\{x_i^-\}_{i=1}^k)-a}{B}:f\in\mathcal{F}\right\}. G = { g f ( z ) = B ℓ ( f , x , x + , { x i − } i = 1 k ) − a : f ∈ F } .
Apply it also to 1 − G 1-\mathcal{G} 1 − G and use a union bound. These two classes have the same empirical Rademacher complexity by symmetry of the signs.
To bound this complexity, set n = d ( k + 2 ) n=d(k+2) n = d ( k + 2 ) and
F ~ = { f ~ ( x , x + , x 1 − , … , x k − ) = ( f ( x ) , f ( x + ) , f ( x 1 − ) , … , f ( x k − ) ) : f ∈ F } . \widetilde{\mathcal{F}}=\left\{\widetilde{f}(x,x^+,x_1^-,\ldots,x_k^-)=(f(x),f(x^+),f(x_1^-),\ldots,f(x_k^-)):f\in\mathcal{F}\right\}. F = { f ( x , x + , x 1 − , … , x k − ) = ( f ( x ) , f ( x + ) , f ( x 1 − ) , … , f ( x k − )) : f ∈ F } .
The normalized loss is L / B L/B L / B -Lipschitz on the representation domain. Lemma 18 gives R S ( G ) ≤ 2 ( L / B ) R S ( F ) \mathcal{R}_S(\mathcal{G})\leq\sqrt{2}(L/B)\mathcal{R}_S(\mathcal{F}) R S ( G ) ≤ 2 ( L / B ) R S ( F ) . Therefore, with probability at least 1 − δ 1-\delta 1 − δ , simultaneously for all f ∈ F f\in\mathcal{F} f ∈ F ,
∣ L c o n ( f ) − L ^ c o n ( f ) ∣ ≤ Γ M ≜ 2 2 L R S ( F ) M + 3 B log ( 4 / δ ) 2 M . (23) \left|L_{\mathrm{con}}(f)-\widehat{L}_{\mathrm{con}}(f)\right|\leq\Gamma_M\triangleq\frac{2\sqrt{2}L\mathcal{R}_S(\mathcal{F})}{M}+3B\sqrt{\frac{\log(4/\delta)}{2M}}. \tag*{(23)} L con ( f ) − L con ( f ) ≤ Γ M ≜ M 2 2 L R S ( F ) + 3 B 2 M log ( 4/ δ ) . (23)
Finally, empirical optimality gives L c o n ( f ^ ) ≤ L ^ c o n ( f ^ ) + Γ M ≤ L ^ c o n ( f ) + Γ M ≤ L c o n ( f ) + 2 Γ M L_{\mathrm{con}}(\hat{f})\leq\widehat{L}_{\mathrm{con}}(\hat{f})+\Gamma_M\leq\widehat{L}_{\mathrm{con}}(f)+\Gamma_M\leq L_{\mathrm{con}}(f)+2\Gamma_M L con ( f ^ ) ≤ L con ( f ^ ) + Γ M ≤ L con ( f ) + Γ M ≤ L con ( f ) + 2 Γ M for every f ∈ F f\in\mathcal{F} f ∈ F , completing the proof. Substituting L ≤ η ζ 1 ( R ) L\leq\eta\zeta_1(R) L ≤ η ζ 1 ( R ) and B ≤ ζ 2 ( R ) B\leq\zeta_2(R) B ≤ ζ 2 ( R ) gives 2 Γ M = G e n M 2\Gamma_M=\mathrm{Gen}_M 2 Γ M = Gen M up to universal constants. ▪
The Rademacher complexity R S ( F ) \mathcal{R}_S(\mathcal{F}) R S ( F ) depends on k k k through the representation tuples. For a concrete capacity bound, consider f A ( x ) = A x f_A(x)=Ax f A ( x ) = A x with ∥ A ∥ F ≤ Λ \|A\|_F\leq\Lambda ∥ A ∥ F ≤ Λ , ∥ x ∥ ≤ R x \|x\|\leq R_x ∥ x ∥ ≤ R x , and Λ R x ≤ R \Lambda R_x\leq R Λ R x ≤ R . Enumerate the M ( k + 2 ) M(k+2) M ( k + 2 ) input occurrences in S S S as z 1 , … , z M ( k + 2 ) z_1,\ldots,z_{M(k+2)} z 1 , … , z M ( k + 2 ) , and let σ j ∈ { ± 1 } d \sigma_j\in\{\pm1\}^d σ j ∈ { ± 1 } d have independent coordinates. Frobenius duality and Cauchy–Schwarz give
R S ( F ) = Λ E σ ∥ ∑ j = 1 M ( k + 2 ) σ j z j T ∥ F ≤ Λ d ∑ j = 1 M ( k + 2 ) ∥ z j ∥ 2 ≤ Λ R x d M ( k + 2 ) . (24) \mathcal{R}_S(\mathcal{F})=\Lambda\mathbb{E}_{\sigma}\left\|\sum_{j=1}^{M(k+2)}\sigma_jz_j^\mathsf{T}\right\|_F\leq\Lambda\sqrt{d\sum_{j=1}^{M(k+2)}\|z_j\|^2}\leq\Lambda R_x\sqrt{dM(k+2)}. \tag*{(24)} R S ( F ) = Λ E σ j = 1 ∑ M ( k + 2 ) σ j z j T F ≤ Λ d j = 1 ∑ M ( k + 2 ) ∥ z j ∥ 2 ≤ Λ R x d M ( k + 2 ) . (24)
Proof of Corollary 6
Proof Fix ( x , y ) (x,y) ( x , y ) and write g c = w c ⊤ f ( x ) g_c = w_c^\top f(x) g c = w c ⊤ f ( x ) . Grouping the k k k negative classes by their values gives
h ( W f ( x ) , y ) = E log [ 1 + k y + ∑ c ≠ y k c e g c − g y ] ≥ h 0 ( y ) . h(Wf(x),y)=\mathbb{E}\log\left[1+k_y+\sum_{c\ne y}k_ce^{g_c-g_y}\right]\ge h_0(y). h ( W f ( x ) , y ) = E log 1 + k y + c = y ∑ k c e g c − g y ≥ h 0 ( y ) .
If y ^ ( x ) ≠ y \hat{y}(x)\ne y y ^ ( x ) = y , then g c ≥ g y g_c\ge g_y g c ≥ g y for c = y ^ ( x ) c=\hat{y}(x) c = y ^ ( x ) , and dropping the other nonnegative terms gives
h ( W f ( x ) , y ) ≥ E log ( 1 + k y + k c ) = h 0 ( y ) + E log ( 1 + k c 1 + k y ) ≥ h 0 ( y ) + ω k ( y ) . h(Wf(x),y)\ge\mathbb{E}\log(1+k_y+k_c)=h_0(y)+\mathbb{E}\log\left(1+\frac{k_c}{1+k_y}\right)\ge h_0(y)+\omega_k(y). h ( W f ( x ) , y ) ≥ E log ( 1 + k y + k c ) = h 0 ( y ) + E log ( 1 + 1 + k y k c ) ≥ h 0 ( y ) + ω k ( y ) .
Hence
h ( W f ( x ) , y ) − h 0 ( y ) ≥ ω k ( y ) I ( y ^ ( x ) ≠ y ) . h(Wf(x),y)-h_0(y)\ge\omega_k(y)\mathbb{I}(\hat{y}(x)\ne y). h ( W f ( x ) , y ) − h 0 ( y ) ≥ ω k ( y ) I ( y ^ ( x ) = y ) .
Taking expectations over x ∼ D y x\sim\mathcal{D}^y x ∼ D y and summing over y y y with weights ρ T ( y ) \rho_T(y) ρ T ( y ) yield
L s u p ( D T , W f , h ) − E y ∼ ρ T h 0 ( y ) ≥ ∑ y ∈ T ρ T ( y ) ω k ( y ) P x ∼ D y [ y ^ ( x ) ≠ y ] . L_{\mathrm{sup}}(\mathcal{D}_T,Wf,h)-\mathbb{E}_{y\sim\rho_T}h_0(y)\ge\sum_{y\in T}\rho_T(y)\omega_k(y)\mathbb{P}_{x\sim\mathcal{D}^y}[\hat{y}(x)\ne y]. L sup ( D T , W f , h ) − E y ∼ ρ T h 0 ( y ) ≥ y ∈ T ∑ ρ T ( y ) ω k ( y ) P x ∼ D y [ y ^ ( x ) = y ] .
Lower bounding ω k ( y ) \omega_k(y) ω k ( y ) by min y ′ ∈ T ω k ( y ′ ) \min_{y'\in T}\omega_k(y') min y ′ ∈ T ω k ( y ′ ) , or ρ T ( y ) ω k ( y ) \rho_T(y)\omega_k(y) ρ T ( y ) ω k ( y ) by min y ′ ∈ T ρ T ( y ′ ) ω k ( y ′ ) \min_{y'\in T}\rho_T(y')\omega_k(y') min y ′ ∈ T ρ T ( y ′ ) ω k ( y ′ ) , proves the two bounds. The final claim follows from Theorem 5 with η = R \eta=R η = R . ■
Proof of Theorem 7
Proof Let w c = E x ∼ D c f ^ ( x ) w_c=\mathbb{E}_{x\sim\mathcal{D}^c}\hat{f}(x) w c = E x ∼ D c f ^ ( x ) , and let W ∈ R ∣ T ∣ × d W\in\mathbb{R}^{|T|\times d} W ∈ R ∣ T ∣ × d have rows w c ⊤ w_c^\top w c ⊤ . Class-conditional independence of positive pairs gives Disc ( f ^ ) = 0 \operatorname{Disc}(\hat{f})=0 Disc ( f ^ ) = 0 . Conditioning on the anchor and the sampled negative classes, Jensen’s inequality gives
L c o n s u p ( f ^ , D ; ℓ ) ≥ E ( x , y ) ∼ D T E { c i } i = 1 k ∼ i . i . d . ρ T ℓ ( f ^ ( x ) , w y , { w c i } i = 1 k ) = L s u p ( D T , W f ^ , h ^ ) , L_{\mathrm{con}}^{\mathrm{sup}}(\hat{f},\mathcal{D};\ell)\ge\mathbb{E}_{(x,y)\sim\mathcal{D}_T}\mathbb{E}_{\{c_i\}_{i=1}^k\overset{\mathrm{i.i.d.}}{\sim}\rho_T}\ell\left(\hat{f}(x),w_y,\{w_{c_i}\}_{i=1}^k\right)
=L_{\mathrm{sup}}(\mathcal{D}_T,W\hat{f},\hat{h}), L con sup ( f ^ , D ; ℓ ) ≥ E ( x , y ) ∼ D T E { c i } i = 1 k ∼ i.i.d. ρ T ℓ ( f ^ ( x ) , w y , { w c i } i = 1 k ) = L sup ( D T , W f ^ , h ^ ) ,
where h h h is the incurred supervised loss stated in the theorem.
For M M M i.i.d. supervised training tuples S S S , the argument based on Rademacher complexity and vector contraction in Theorem 19 applies to the empirical minimizer f ^ \hat{f} f ^ . Thus, with probability at least 1 − δ 1-\delta 1 − δ , for all f ∈ F f\in\mathcal{F} f ∈ F ,
L c o n s u p ( f ^ , D ; ℓ ) ≤ L c o n s u p ( f , D ; ℓ ) + Gen M , L_{\mathrm{con}}^{\mathrm{sup}}(\hat{f},\mathcal{D};\ell)\le L_{\mathrm{con}}^{\mathrm{sup}}(f,\mathcal{D};\ell)+\operatorname{Gen}_M, L con sup ( f ^ , D ; ℓ ) ≤ L con sup ( f , D ; ℓ ) + Gen M ,
where Gen M \operatorname{Gen}_M Gen M is as in Theorem 5 , with the empirical Rademacher complexity evaluated on S S S . Combining the inequalities completes the proof. ■
Proof of Proposition 8
Proof We first bound the estimation error of Disc ^ i \widehat{\operatorname{Disc}}_i Disc i uniformly over F \mathcal{F} F . For f ∈ F f\in\mathcal{F} f ∈ F , write μ c = E x ∼ D c f ( x ) \mu_c=\mathbb{E}_{x\sim\mathcal{D}^c}f(x) μ c = E x ∼ D c f ( x ) and I c = { n : y x n = c } I_c=\{n:y_{x_n}=c\} I c = { n : y x n = c } , and let
Disc ^ i ( f ) = 1 N ∑ n = 1 N ∥ f ( x n ) − μ y x n ∥ , \widehat{\operatorname{Disc}}_i(f)=\frac{1}{N}\sum_{n=1}^{N}\left\|f(x_n)-\mu_{y_{x_n}}\right\|, Disc i ( f ) = N 1 n = 1 ∑ N f ( x n ) − μ y x n ,
whose expectation is Disc i ( f ) \operatorname{Disc}_i(f) Disc i ( f ) . Since N c ( μ ^ c − μ c ) = ∑ n ∈ I c ( f ( x n ) − μ c ) N_c(\widehat{\mu}_c-\mu_c)=\sum_{n\in I_c}(f(x_n)-\mu_c) N c ( μ c − μ c ) = ∑ n ∈ I c ( f ( x n ) − μ c ) , the triangle inequality and ∥ v ∥ = sup ∥ u ∥ ≤ 1 u ⊤ v \|v\|=\sup_{\|u\|\le1}u^\top v ∥ v ∥ = sup ∥ u ∥ ≤ 1 u ⊤ v give
∣ Disc ^ i ( f ) − Disc ~ i ( f ) ∣ ≤ 1 N ∑ c ∈ T ∥ ∑ n ∈ I c ( f ( x n ) − μ c ) ∥ = sup { u c } c ∈ T ⊆ B 1 N ∑ n = 1 N u y x n ⊤ ( f ( x n ) − μ y x n ) , \left|\widehat{\operatorname{Disc}}_i(f)-\widetilde{\operatorname{Disc}}_i(f)\right|
\le\frac{1}{N}\sum_{c\in T}\left\|\sum_{n\in I_c}(f(x_n)-\mu_c)\right\|
=\sup_{\{u_c\}_{c\in T}\subseteq\mathbb{B}}\frac{1}{N}\sum_{n=1}^{N}u_{y_{x_n}}^\top(f(x_n)-\mu_{y_{x_n}}), Disc i ( f ) − Disc i ( f ) ≤ N 1 c ∈ T ∑ n ∈ I c ∑ ( f ( x n ) − μ c ) = { u c } c ∈ T ⊆ B sup N 1 n = 1 ∑ N u y x n ⊤ ( f ( x n ) − μ y x n ) ,
where B \mathcal{B} B is the unit ball in R d \mathbb{R}^{d} R d and every summand has zero mean. We apply the classical empirical Rademacher bound in the proof of Theorem 19 , with δ / 3 \delta/3 δ /3 in place of δ \delta δ , to G 1 = { ∥ f ( x ) − μ y x ∥ : f ∈ F } \mathcal{G}_1 = \{\lVert f(x)-\mu_{y_x}\rVert: f \in\mathcal{F}\} G 1 = {∥ f ( x ) − μ y x ∥ : f ∈ F } in both directions and to G 2 = { u y x ⊤ ( f ( x ) − μ y x ) : f ∈ F , { u c } c ∈ T ⊆ B } \mathcal{G}_2 = \{u_{y_x}^{\top}(f(x)-\mu_{y_x}) : f \in\mathcal{F}, \{u_c\}_{c\in\mathcal{T}} \subseteq\mathcal{B}\} G 2 = { u y x ⊤ ( f ( x ) − μ y x ) : f ∈ F , { u c } c ∈ T ⊆ B } in one direction. Their values lie in intervals of length 2 R 2R 2 R and 4 R 4R 4 R , so with probability at least 1 − δ / 2 1-\delta/2 1 − δ /2 , for all f ∈ F f\in\mathcal{F} f ∈ F ,
∣ Disc ^ i ( f ) − Disc i ( f ) ∣ ≤ 2 R S ′ ( G 1 ) + 2 R S ′ ( G 2 ) N + 18 R log ( 12 / δ ) 2 N . \left|\widehat{\operatorname{Disc}}_i(f)-\operatorname{Disc}_i(f)\right|
\leq\frac{2R\mathcal{S}'(\mathcal{G}_1)+2R\mathcal{S}'(\mathcal{G}_2)}{N}
+18R\sqrt{\frac{\log(12/\delta)}{2N}}. Disc i ( f ) − Disc i ( f ) ≤ N 2 R S ′ ( G 1 ) + 2 R S ′ ( G 2 ) + 18 R 2 N log ( 12/ δ ) .
To bound these complexities, let σ n , σ n ′ ∈ { ± 1 } d \sigma_n,\sigma'_n\in\{\pm1\}^{d} σ n , σ n ′ ∈ { ± 1 } d have independent Rademacher coordinates. Since ∥ μ c ∥ ≤ R \lVert\mu_c\rVert\leq R ∥ μ c ∥ ≤ R , E σ ∥ ∑ n ∈ I c σ n ∥ ≤ d N c \mathbb{E}_{\sigma}\lVert\sum_{n\in I_c}\sigma_n\rVert\leq\sqrt{dN_c} E σ ∥ ∑ n ∈ I c σ n ∥ ≤ d N c , and ∑ c ∈ T N c ≤ ∣ T ∣ N \sum_{c\in\mathcal{T}}\sqrt{N_c}\leq\sqrt{|\mathcal{T}|N} ∑ c ∈ T N c ≤ ∣ T ∣ N , we have
E σ sup f ∈ F ∑ n = 1 N σ n ⊤ ( f ( x n ) − μ y x n ) ≤ R S ′ ( F ) + R ∑ c ∈ T E σ ∥ ∑ n ∈ I c σ n ∥ ≤ R S ′ ( F ) + R d ∣ T ∣ N , \mathbb{E}_{\sigma}\sup_{f\in\mathcal{F}}\sum_{n=1}^{N}\sigma_n^{\top}(f(x_n)-\mu_{y_{x_n}})
\leq R\mathcal{S}'(\mathcal{F})+R\sum_{c\in\mathcal{T}}\mathbb{E}_{\sigma}\left\lVert\sum_{n\in I_c}\sigma_n\right\rVert
\leq R\mathcal{S}'(\mathcal{F})+R\sqrt{d|\mathcal{T}|N}, E σ f ∈ F sup n = 1 ∑ N σ n ⊤ ( f ( x n ) − μ y x n ) ≤ R S ′ ( F ) + R c ∈ T ∑ E σ n ∈ I c ∑ σ n ≤ R S ′ ( F ) + R d ∣ T ∣ N ,
and similarly E σ ′ sup { u c } c ∈ T ⊆ B ∑ n = 1 N 2 R σ n ′ ⊤ u y x n ≤ 2 R d ∣ T ∣ N \mathbb{E}_{\sigma'}\sup_{\{u_c\}_{c\in\mathcal{T}}\subseteq\mathcal{B}}\sum_{n=1}^{N}2R\sigma_n'^{\top}u_{y_{x_n}}\leq2R\sqrt{d|\mathcal{T}|N} E σ ′ sup { u c } c ∈ T ⊆ B ∑ n = 1 N 2 R σ n ′ ⊤ u y x n ≤ 2 R d ∣ T ∣ N . The classes G 1 \mathcal{G}_1 G 1 and G 2 \mathcal{G}_2 G 2 are obtained by applying the 1 1 1 -Lipschitz map v ↦ ∥ v ∥ v\mapsto\lVert v\rVert v ↦ ∥ v ∥ to f ( x ) − μ y x f(x)-\mu_{y_x} f ( x ) − μ y x and the map ( a , b ) ↦ a ⊤ b / ( 2 R ) (a,b)\mapsto a^{\top}b/(2R) ( a , b ) ↦ a ⊤ b / ( 2 R ) , which is 2 \sqrt{2} 2 -Lipschitz on { ∥ a ∥ , ∥ b ∥ ≤ 2 R } \{\lVert a\rVert,\lVert b\rVert\leq2R\} {∥ a ∥ , ∥ b ∥ ≤ 2 R } , to ( 2 R u y x , f ( x ) − μ y x ) (2Ru_{y_x},f(x)-\mu_{y_x}) ( 2 R u y x , f ( x ) − μ y x ) . By Lemma 18 , R S ′ ( G 1 ) ≤ 2 ( R S ′ ( F ) + R d ∣ T ∣ N ) R\mathcal{S}'(\mathcal{G}_1)\leq\sqrt{2}(R\mathcal{S}'(\mathcal{F})+R\sqrt{d|\mathcal{T}|N}) R S ′ ( G 1 ) ≤ 2 ( R S ′ ( F ) + R d ∣ T ∣ N ) and R S ′ ( G 2 ) ≤ 2 ( R S ′ ( F ) + 3 R d ∣ T ∣ N ) R\mathcal{S}'(\mathcal{G}_2)\leq2(R\mathcal{S}'(\mathcal{F})+3R\sqrt{d|\mathcal{T}|N}) R S ′ ( G 2 ) ≤ 2 ( R S ′ ( F ) + 3 R d ∣ T ∣ N ) . Hence, with probability at least 1 − δ / 2 1-\delta/2 1 − δ /2 ,
sup f ∈ F ∣ Disc ^ i ( f ) − Disc i ( f ) ∣ ≤ Γ N ≜ 7 R S ′ ( F ) + 15 R d ∣ T ∣ N N + 18 R log ( 12 / δ ) 2 N . \sup_{f\in\mathcal{F}}\left|\widehat{\operatorname{Disc}}_i(f)-\operatorname{Disc}_i(f)\right|
\leq\Gamma_N\triangleq
\frac{7R\mathcal{S}'(\mathcal{F})+15R\sqrt{d|\mathcal{T}|N}}{N}
+18R\sqrt{\frac{\log(12/\delta)}{2N}}. f ∈ F sup Disc i ( f ) − Disc i ( f ) ≤ Γ N ≜ N 7 R S ′ ( F ) + 15 R d ∣ T ∣ N + 18 R 2 N log ( 12/ δ ) .
By Equation (23) with δ / 2 \delta/2 δ /2 in place of δ \delta δ , with probability at least 1 − δ / 2 1-\delta/2 1 − δ /2 , sup f ∈ F ∣ L c o n ( f ) − L ^ c o n ( f ) ∣ ≤ Γ M \sup_{f\in\mathcal{F}}|L_{\mathrm{con}}(f)-\widehat{L}_{\mathrm{con}}(f)|\leq\Gamma_M sup f ∈ F ∣ L con ( f ) − L con ( f ) ∣ ≤ Γ M . On the intersection of both events, the definition of f ^ \hat{f} f ^ implies, for every f ∈ F f\in\mathcal{F} f ∈ F ,
L c o n ( f ^ ) + η Disc i ( f ^ ) ≤ L ^ c o n ( f ^ ) + η Disc ^ i ( f ^ ) + Γ M + η Γ N ≤ L ^ c o n ( f ) + η Disc ^ i ( f ) + Γ M + η Γ N ≤ L c o n ( f ) + η Disc i ( f ) + 2 Γ M + 2 η Γ N . \begin{aligned}
L_{\mathrm{con}}(\hat{f})+\eta\operatorname{Disc}_i(\hat{f})
\leq\widehat{L}_{\mathrm{con}}(\hat{f})+\eta\widehat{\operatorname{Disc}}_i(\hat{f})+\Gamma_M+\eta\Gamma_N \\
&\leq\widehat{L}_{\mathrm{con}}(f)+\eta\widehat{\operatorname{Disc}}_i(f)+\Gamma_M+\eta\Gamma_N \\
&\leq L_{\mathrm{con}}(f)+\eta\operatorname{Disc}_i(f)+2\Gamma_M+2\eta\Gamma_N.
\end{aligned} L con ( f ^ ) + η Disc i ( f ^ ) ≤ L con ( f ^ ) + η Disc i ( f ^ ) + Γ M + η Γ N ≤ L con ( f ) + η Disc i ( f ) + Γ M + η Γ N ≤ L con ( f ) + η Disc i ( f ) + 2 Γ M + 2 η Γ N .
By the triangle inequality and Jensen’s inequality, Disc ( f ^ ) ≤ Disc a ( f ^ ) + Disc i ( f ^ ) \operatorname{Disc}(\hat{f})\leq\operatorname{Disc}_a(\hat{f})+\operatorname{Disc}_i(\hat{f}) Disc ( f ^ ) ≤ Disc a ( f ^ ) + Disc i ( f ^ ) as in § 3.1 . Applying Theorem 2 to f ^ \hat{f} f ^ , we obtain
L s u p ( D T , W f ^ , h ) ≤ L c o n ( f ^ ) + η Disc ( f ^ ) ≤ L c o n ( f ^ ) + η Disc i ( f ^ ) + η Disc a ( f ^ ) . L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},W_{\hat{f}},h)
\leq L_{\mathrm{con}}(\hat{f})+\eta\operatorname{Disc}(\hat{f})
\leq L_{\mathrm{con}}(\hat{f})+\eta\operatorname{Disc}_i(\hat{f})+\eta\operatorname{Disc}_a(\hat{f}). L sup ( D T , W f ^ , h ) ≤ L con ( f ^ ) + η Disc ( f ^ ) ≤ L con ( f ^ ) + η Disc i ( f ^ ) + η Disc a ( f ^ ) .
Combining it with the previous display, taking the infimum over f ∈ F f\in\mathcal{F} f ∈ F , and noting that 2 Γ M = G e n M 2\Gamma_M=\mathrm{Gen}_M 2 Γ M = Gen M and 2 Γ N = G e n N 2\Gamma_N=\mathrm{Gen}_N 2 Γ N = Gen N up to universal constants complete the proof. ■
Proof of Proposition 9
Proof Let I c = { n : y x n = c } I_c=\{n:y_{x_n}=c\} I c = { n : y x n = c } for c ∈ T c\in\mathcal{T} c ∈ T , and split L ^ k -means ( f ) = L ^ w ( f ) + L ^ b ( f ) \widehat{L}_{k\text{-means}}(f)=\widehat{L}_w(f)+\widehat{L}_b(f) L k -means ( f ) = L w ( f ) + L b ( f ) , where L ^ w ( f ) \widehat{L}_w(f) L w ( f ) sums over the pairs ( i , j ) (i,j) ( i , j ) from the same class and L ^ b ( f ) \widehat{L}_b(f) L b ( f ) over the N 2 − ∑ c ∈ T N c 2 N^2-\sum_{c\in\mathcal{T}}N_c^2 N 2 − ∑ c ∈ T N c 2 pairs from different classes. Each summand of L ^ b ( f ) \widehat{L}_b(f) L b ( f ) lies in [ 0 , τ ] [0,\tau] [ 0 , τ ] , so 0 ≤ L ^ b ( f ) ≤ τ ( N 2 − ∑ c ∈ T N c 2 ) 0\leq\widehat{L}_b(f)\leq\tau\left(N^2-\sum_{c\in\mathcal{T}}N_c^2\right) 0 ≤ L b ( f ) ≤ τ ( N 2 − ∑ c ∈ T N c 2 ) , and the upper bound holds with equality under the additional condition. It therefore suffices to show that
τ N min N 2 R Disc ^ i ( f ) ≤ L ^ w ( f ) ≤ 2 N max N Disc ^ i ( f ) . \frac{\tau N_{\min}N}{2R}\widehat{\operatorname{Disc}}_{\mathrm{i}}(f) \le\widehat{L}_{\mathrm{w}}(f) \le2N_{\max}N\widehat{\operatorname{Disc}}_{\mathrm{i}}(f). 2 R τ N m i n N Disc i ( f ) ≤ L w ( f ) ≤ 2 N m a x N Disc i ( f ) .
Since ∥ f ( x ) ∥ ≤ R \lVert f(x)\rVert\le R ∥ f ( x )∥ ≤ R , all pairwise distances lie in [ 0 , 2 R ] [0,2R] [ 0 , 2 R ] , on which min { a , τ } ≥ τ a / ( 2 R ) \min\{a,\tau\} \ge\tau a/(2R) min { a , τ } ≥ τ a / ( 2 R ) as τ ≤ 2 R \tau\le2R τ ≤ 2 R . For i ∈ I c i \in I_c i ∈ I c , Jensen’s inequality gives ∑ j ∈ I c ∥ f ( x i ) − f ( x j ) ∥ ≥ N c ∥ f ( x i ) − μ ^ c ∥ \sum_{j\in I_c}\lVert f(x_i)-f(x_j)\rVert\ge N_c\lVert f(x_i)-\widehat{\mu}_c\rVert ∑ j ∈ I c ∥ f ( x i ) − f ( x j )∥ ≥ N c ∥ f ( x i ) − μ c ∥ . Hence
L ^ w ( f ) ≥ τ 2 R ∑ c ∈ T N c ∑ i ∈ I c ∥ f ( x i ) − μ ^ c ∥ ≥ τ N min N 2 R Disc ^ i ( f ) . \widehat{L}_{\mathrm{w}}(f) \ge\frac{\tau}{2R}\sum_{c\in\mathcal{T}}N_c\sum_{i\in I_c}\lVert f(x_i)-\widehat{\mu}_c\rVert\ge\frac{\tau N_{\min}N}{2R}\widehat{\operatorname{Disc}}_{\mathrm{i}}(f). L w ( f ) ≥ 2 R τ c ∈ T ∑ N c i ∈ I c ∑ ∥ f ( x i ) − μ c ∥ ≥ 2 R τ N m i n N Disc i ( f ) .
Conversely, for i , j ∈ I c i,j\in I_c i , j ∈ I c , the triangle inequality gives min { ∥ f ( x i ) − f ( x j ) ∥ , τ } ≤ ∥ f ( x i ) − μ ^ c ∥ + ∥ f ( x j ) − μ ^ c ∥ \min\{\lVert f(x_i)-f(x_j)\rVert,\tau\}\le\lVert f(x_i)-\widehat{\mu}_c\rVert+\lVert f(x_j)-\widehat{\mu}_c\rVert min {∥ f ( x i ) − f ( x j )∥ , τ } ≤ ∥ f ( x i ) − μ c ∥ + ∥ f ( x j ) − μ c ∥ . Summing over i , j ∈ I c i,j\in I_c i , j ∈ I c and c ∈ T c\in\mathcal{T} c ∈ T yields
L ^ w ( f ) ≤ 2 ∑ c ∈ T N c ∑ i ∈ I c ∥ f ( x i ) − μ ^ c ∥ ≤ 2 N max N Disc ^ i ( f ) , \widehat{L}_{\mathrm{w}}(f) \le2\sum_{c\in\mathcal{T}}N_c\sum_{i\in I_c}\lVert f(x_i)-\widehat{\mu}_c\rVert\le2N_{\max}N\widehat{\operatorname{Disc}}_{\mathrm{i}}(f), L w ( f ) ≤ 2 c ∈ T ∑ N c i ∈ I c ∑ ∥ f ( x i ) − μ c ∥ ≤ 2 N m a x N Disc i ( f ) ,
which completes the proof.
Implications for Mitigating Class Imbalance
Proof of Theorem 10
To prove that h = h ~ + log k + O ( k − 1 ) h=\widetilde{h}+\log k+O(k^{-1}) h = h + log k + O ( k − 1 ) under the condition that ∥ f ( x ) ∥ , ∥ w c ∥ ≤ R \lVert f(x)\rVert,\lVert w_c\rVert\le R ∥ f ( x )∥ , ∥ w c ∥ ≤ R , we introduce h ‾ ( x , y ) ≜ log [ 1 + k E c ∼ ρ T e f ( x ) T ( w c − w y ) ] \overline{h}(x,y)\triangleq\log[1+k\mathbb{E}_{c\sim\rho_{\mathcal{T}}}e^{f(x)^{\mathsf{T}}(w_c-w_y)}] h ( x , y ) ≜ log [ 1 + k E c ∼ ρ T e f ( x ) T ( w c − w y ) ] . We bound the Jensen gap using a second-order bound on the logarithm, as detailed in Lemma 20 below. Its lower bound gives h ~ + log k ≤ h + V R / k \widetilde{h}+\log k\le h+V_R/k h + log k ≤ h + V R / k , where V R = ( e R 2 − 1 ) 2 / 2 V_R=(e^{R^2}-1)^2/2 V R = ( e R 2 − 1 ) 2 /2 . Combining this with Theorem 5 , we can deduce
L s u p ( D T , W f ^ , h ~ ) + log k ≤ L c o n ( f ) + η ⋅ Disc ( f ^ ) + Gen M + V R k . L_{\mathrm{sup}}(\mathcal{D}_{\mathcal{T}},W\widehat{f},\widetilde{h})+\log k\le L_{\mathrm{con}}(f)+\eta\cdot\operatorname{Disc}(\widehat{f})+\operatorname{Gen}_{M}+\frac{V_R}{k}. L sup ( D T , W f , h ) + log k ≤ L con ( f ) + η ⋅ Disc ( f ) + Gen M + k V R .
Lemma 20. Assume ∥ f ( x ) ∥ , ∥ w c ∥ ≤ R \lVert f(x)\rVert,\lVert w_c\rVert\le R ∥ f ( x )∥ , ∥ w c ∥ ≤ R . For h ‾ ( x , y ) = log [ 1 + k E c ∼ ρ T e f ( x ) T ( w c − w y ) ] \overline{h}(x,y)=\log[1+k\mathbb{E}_{c\sim\rho_{\mathcal{T}}}e^{f(x)^{\mathsf{T}}(w_c-w_y)}] h ( x , y ) = log [ 1 + k E c ∼ ρ T e f ( x ) T ( w c − w y ) ] , we denote its (biased) Monte Carlo estimate with k k k i.i.d. random samples c i ∼ ρ T c_i\sim\rho_{\mathcal{T}} c i ∼ ρ T , i = 1 , … , k i=1,\ldots,k i = 1 , … , k , by h ^ ( x , y , { c i } i = 1 k ) ≜ log [ 1 + ∑ i = 1 k e f ( x ) T ( w c i − w y ) ] \widehat{h}(x,y,\{c_i\}_{i=1}^{k})\triangleq\log\left[1+\sum_{i=1}^{k}e^{f(x)^{\mathsf{T}}(w_{c_i}-w_y)}\right] h ( x , y , { c i } i = 1 k ) ≜ log [ 1 + ∑ i = 1 k e f ( x ) T ( w c i − w y ) ] . Then h ( x , y ) = E { c i } i = 1 k ∼ i . i . d . ρ T h ^ ( x , y , { c i } i = 1 k ) h(x,y)=\mathbb{E}_{\{c_i\}_{i=1}^{k}\overset{\mathrm{i.i.d.}}{\sim}\rho_{\mathcal{T}}}\widehat{h}(x,y,\{c_i\}_{i=1}^{k}) h ( x , y ) = E { c i } i = 1 k ∼ i.i.d. ρ T h ( x , y , { c i } i = 1 k ) . Let U R = e 2 R 2 U_R=e^{2R^2} U R = e 2 R 2 and V R = ( e R 2 − 1 ) 2 / 2 V_R=(e^{R^2}-1)^2/2 V R = ( e R 2 − 1 ) 2 /2 . Then
− V R k ≤ h ( x , y ) − log k − h ~ ( x , y ) ≤ min { U R , 1 / ρ T ( y ) } k . (25) -\frac{V_R}{k}\le h(x,y)-\log k-\widetilde{h}(x,y)\le\frac{\min\{U_R,1/\rho_{\mathcal{T}}(y)\}}{k}. \tag*{(25)} − k V R ≤ h ( x , y ) − log k − h ( x , y ) ≤ k min { U R , 1/ ρ T ( y )} . (25) Consequently, since V R < U R V_R<U_R V R < U R , ∣ h − log k − h ~ ∣ ≤ U R / k \lvert h-\log k-\widetilde{h}\rvert\le U_R/k ∣ h − log k − h ∣ ≤ U R / k .
Proof Fix ( x , y ) (x,y) ( x , y ) and let Z i = e f ( x ) T ( w c i − w y ) Z_i=e^{f(x)^{\mathsf{T}}(w_{c_i}-w_y)} Z i = e f ( x ) T ( w c i − w y ) , m = E Z 1 m=\mathbb{E}Z_1 m = E Z 1 , and Z ‾ = k − 1 ∑ i = 1 k Z i \overline{Z}=k^{-1}\sum_{i=1}^{k}Z_i Z = k − 1 ∑ i = 1 k Z i . Writing s = f ( x ) T w y s=f(x)^{\mathsf{T}}w_y s = f ( x ) T w y , a = e − R 2 − s a=e^{-R^2-s} a = e − R 2 − s , and b = e R 2 − s b=e^{R^2-s} b = e R 2 − s , the norm constraints imply ∣ f ( x ) T w c ∣ ≤ R 2 \lvert f(x)^{\mathsf{T}}w_c\rvert\le R^2 ∣ f ( x ) T w c ∣ ≤ R 2 , so a ≤ Z i ≤ b a\le Z_i\le b a ≤ Z i ≤ b with b / a = e 2 R 2 b/a=e^{2R^2} b / a = e 2 R 2 . Hence
h − log k = E log ( Z ‾ + 1 / k ) , h ~ = log m . h-\log k=\mathbb{E}\log(\overline{Z}+1/k),\qquad\widetilde{h}=\log m. h − log k = E log ( Z + 1/ k ) , h = log m .
Let X = Z ˉ + 1 / k X=\bar{Z}+1/k X = Z ˉ + 1/ k and ν = m + 1 / k \nu=m+1/k ν = m + 1/ k , so that E X = ν \mathbb{E}X=\nu E X = ν and X , ν ≥ a + 1 / k X,\nu\ge a+1/k X , ν ≥ a + 1/ k . For u > 0 u>0 u > 0 , integrating 1 / s − 1 1/s-1 1/ s − 1 between u u u and 1 1 1 gives − log u ≤ 1 − u + ( 1 − u ) 2 2 min { u , 1 } -\log u\le1-u+\frac{(1-u)^2}{2\min\{u,1\}} − log u ≤ 1 − u + 2 m i n { u , 1 } ( 1 − u ) 2 . Applying it with u = X / ν u=X/\nu u = X / ν and taking expectations, the linear term vanishes. Together with Jensen’s inequality, this gives
0 ≤ J ≜ h ~ − h = log ( m + 1 / k ) − E log ( Z ˉ + 1 / k ) ≤ E ( X − ν ) 2 2 ν min { X , ν } ≤ Var ( Z 1 ) 2 k m a ≤ ( b − m ) ( m − a ) 2 k m a ≤ ( b − a ) 2 2 k a = V R k , (26) \begin{aligned}
0\le J\triangleq\tilde{h}-h&=\log(m+1/k)-\mathbb{E}\log(\bar{Z}+1/k)\\
&\le\mathbb{E}\frac{(X-\nu)^2}{2\nu\min\{X,\nu\}}\\
&\le\frac{\operatorname{Var}(Z_1)}{2kma}\le\frac{(b-m)(m-a)}{2kma}\le\frac{(\sqrt{b}-\sqrt{a})^2}{2ka}=\frac{V_R}{k}, \tag*{(26)}
\end{aligned} 0 ≤ J ≜ h ~ − h = log ( m + 1/ k ) − E log ( Z ˉ + 1/ k ) ≤ E 2 ν min { X , ν } ( X − ν ) 2 ≤ 2 k ma Var ( Z 1 ) ≤ 2 k ma ( b − m ) ( m − a ) ≤ 2 k a ( b − a ) 2 = k V R , (26)
where independence gives Var ( X ) = Var ( Z 1 ) / k \operatorname{Var}(X)=\operatorname{Var}(Z_1)/k Var ( X ) = Var ( Z 1 ) / k , taking expectations in ( b − Z 1 ) ( Z 1 − a ) ≥ 0 (b-Z_1)(Z_1-a)\ge0 ( b − Z 1 ) ( Z 1 − a ) ≥ 0 gives Var ( Z 1 ) ≤ ( b − m ) ( m − a ) \operatorname{Var}(Z_1)\le(b-m)(m-a) Var ( Z 1 ) ≤ ( b − m ) ( m − a ) , and m + a b / m ≥ 2 a b m+ab/m\ge2\sqrt{ab} m + ab / m ≥ 2 ab gives the last inequality. Also, using m ≥ a ≥ e − 2 R 2 m\ge a\ge e^{-2R^2} m ≥ a ≥ e − 2 R 2 and m ≥ ρ T ( y ) m\ge\rho_T(y) m ≥ ρ T ( y ) , which holds as Z i = 1 Z_i=1 Z i = 1 whenever c i = y c_i=y c i = y , we have
0 ≤ log ( m + 1 / k ) − log m = log ( 1 + 1 k m ) ≤ 1 k m ≤ min { U R , 1 / ρ T ( y ) } k . (27) 0\le\log(m+1/k)-\log m=\log\left(1+\frac{1}{km}\right)\le\frac{1}{km}\le\frac{\min\{U_R,1/\rho_T(y)\}}{k}. \tag*{(27)} 0 ≤ log ( m + 1/ k ) − log m = log ( 1 + k m 1 ) ≤ k m 1 ≤ k min { U R , 1/ ρ T ( y )} . (27)
Since h − log k − h ~ = log ( 1 + 1 / ( k m ) ) − J h-\log k-\tilde{h}=\log(1+1/(km))-J h − log k − h ~ = log ( 1 + 1/ ( k m )) − J , Equations 26 and 27 prove the claimed bounds.
■ \blacksquare ■
The order k − 1 k^{-1} k − 1 cannot in general be improved under these assumptions: when all logits are zero, Z i ≡ 1 Z_i\equiv1 Z i ≡ 1 and h − log k − h ~ = log ( 1 + 1 / k ) ∼ k − 1 h-\log k-\tilde{h}=\log(1+1/k)\sim k^{-1} h − log k − h ~ = log ( 1 + 1/ k ) ∼ k − 1 .
Proof of Theorem 11
Proof. The SpeCL-incurred supervised loss is formulated as h ( x , y ) = − 2 f ( x ) ⊤ w y + E c ∼ ρ T ( f ( x ) ⊤ w c ) 2 h(x,y)=-2f(x)^\top w_y+\mathbb{E}_{c\sim\rho_T}(f(x)^\top w_c)^2 h ( x , y ) = − 2 f ( x ) ⊤ w y + E c ∼ ρ T ( f ( x ) ⊤ w c ) 2 . Let μ c = E x ∼ D c f ( x ) \mu_c=\mathbb{E}_{x\sim\mathcal{D}_c}f(x) μ c = E x ∼ D c f ( x ) for c ∈ T c\in\mathcal{T} c ∈ T . Then the population risk is
L = E ( x , y ) ∼ D T h ( x , y ) = E ( x , y ) ∼ D T [ − 2 f ( x ) ⊤ w y + E c ∼ ρ T ( f ( x ) ⊤ w c ) 2 ] ≥ E c ∼ ρ T [ − 2 μ c ⊤ w c + E c ′ ∼ ρ T ( μ c ⊤ w c ′ ) 2 ] = − 2 ∑ c ∈ T ρ T ( c ) μ c ⊤ w c + ∑ c , c ′ ∈ T ρ T ( c ) ρ T ( c ′ ) ( μ c ⊤ w c ′ ) 2 = ∑ c ∈ T [ ρ T 2 ( c ) ( μ c ⊤ w c ) 2 − 2 ρ T ( c ) μ c ⊤ w c ] + ∑ c ≠ c ′ , c , c ′ ∈ T ρ T ( c ) ρ T ( c ′ ) ( μ c ⊤ w c ′ ) 2 = ∑ c ∈ T [ ρ T ( c ) μ c ⊤ w c − 1 ] 2 + ∑ c ≠ c ′ , c , c ′ ∈ T ρ T ( c ) ρ T ( c ′ ) ( μ c ⊤ w c ′ ) 2 − ∣ T ∣ = ∥ ( ρ T ( c ) μ c ) c ∈ T ⊤ ( ρ T ( c ) w c ) c ∈ T − I ∣ T ∣ ∥ F 2 − ∣ T ∣ . \begin{aligned}
\mathcal{L}
&=\mathbb{E}_{(x,y)\sim\mathcal{D}_T}h(x,y)
=\mathbb{E}_{(x,y)\sim\mathcal{D}_T}\left[-2f(x)^\top w_y+\mathbb{E}_{c\sim\rho_T}(f(x)^\top w_c)^2\right]\\
&\ge\mathbb{E}_{c\sim\rho_T}\left[-2\mu_c^\top w_c+\mathbb{E}_{c'\sim\rho_T}(\mu_c^\top w_{c'})^2\right]\\
&=-2\sum_{c\in\mathcal{T}}\rho_T(c)\mu_c^\top w_c+\sum_{c,c'\in\mathcal{T}}\rho_T(c)\rho_T(c')(\mu_c^\top w_{c'})^2\\
&=\sum_{c\in\mathcal{T}}\left[\rho_T^2(c)(\mu_c^\top w_c)^2-2\rho_T(c)\mu_c^\top w_c\right]+\sum_{c\ne c',c,c'\in\mathcal{T}}\rho_T(c)\rho_T(c')(\mu_c^\top w_{c'})^2\\
&=\sum_{c\in\mathcal{T}}\left[\rho_T(c)\mu_c^\top w_c-1\right]^2+\sum_{c\ne c',c,c'\in\mathcal{T}}\rho_T(c)\rho_T(c')(\mu_c^\top w_{c'})^2-|\mathcal{T}|\\
&=\left\|\left(\sqrt{\rho_T(c)}\mu_c\right)_{c\in\mathcal{T}}^\top\left(\sqrt{\rho_T(c)}w_c\right)_{c\in\mathcal{T}}-I_{|\mathcal{T}|}\right\|_F^2-|\mathcal{T}|.
\end{aligned} L = E ( x , y ) ∼ D T h ( x , y ) = E ( x , y ) ∼ D T [ − 2 f ( x ) ⊤ w y + E c ∼ ρ T ( f ( x ) ⊤ w c ) 2 ] ≥ E c ∼ ρ T [ − 2 μ c ⊤ w c + E c ′ ∼ ρ T ( μ c ⊤ w c ′ ) 2 ] = − 2 c ∈ T ∑ ρ T ( c ) μ c ⊤ w c + c , c ′ ∈ T ∑ ρ T ( c ) ρ T ( c ′ ) ( μ c ⊤ w c ′ ) 2 = c ∈ T ∑ [ ρ T 2 ( c ) ( μ c ⊤ w c ) 2 − 2 ρ T ( c ) μ c ⊤ w c ] + c = c ′ , c , c ′ ∈ T ∑ ρ T ( c ) ρ T ( c ′ ) ( μ c ⊤ w c ′ ) 2 = c ∈ T ∑ [ ρ T ( c ) μ c ⊤ w c − 1 ] 2 + c = c ′ , c , c ′ ∈ T ∑ ρ T ( c ) ρ T ( c ′ ) ( μ c ⊤ w c ′ ) 2 − ∣ T ∣ = ( ρ T ( c ) μ c ) c ∈ T ⊤ ( ρ T ( c ) w c ) c ∈ T − I ∣ T ∣ F 2 − ∣ T ∣.
Let C = ∣ T ∣ C=|\mathcal{T}| C = ∣ T ∣ and r = min { d , C } r=\min\{d,C\} r = min { d , C } . Since the matrix product above has rank at most d d d , L ≥ − r \mathcal{L}\ge-r L ≥ − r . This lower bound is attained: choose r r r classes c 1 , … , c r c_1,\ldots,c_r c 1 , … , c r , set f ( x ) = e j f(x)=e_j f ( x ) = e j for x ∼ D c j x\sim\mathcal{D}_{c_j} x ∼ D c j and w c j = e j / ρ T ( c j ) w_{c_j}=e_j/\rho_T(c_j) w c j = e j / ρ T ( c j ) , and set the representations and classifier weights of the remaining classes to zero. Here e 1 , … , e r e_1,\ldots,e_r e 1 , … , e r are standard basis vectors. Therefore, the minimum risk is − r -r − r for every strictly positive class distribution, including the uniform distribution.
Writing L ρ T ( f , W ) \mathcal{L}_{\rho_T}(f,W) L ρ T ( f , W ) for the risk under ρ T \rho_T ρ T and L u n i f ( f , W ) \mathcal{L}_{\mathrm{unif}}(f,W) L unif ( f , W ) for the risk under the uniform distribution, direct substitution of the stated transformations gives, for every pair ( f ~ , W ~ ) (\tilde{f},\widetilde{W}) ( f ~ , W ) ,
L ρ T ( f ^ , W ^ ) = − 2 C ∑ c ∈ T E x ∼ D c f ~ ( x ) T w ~ c + 1 C 2 ∑ c , c ′ ∈ T ( E x ∼ D c ( f ~ ( x ) T w ~ c ′ ) ) 2 = L u n i f ( f ~ , W ~ ) . \mathcal{L}_{\rho_T}(\hat{f},\widehat{W})=-\frac{2}{C}\sum_{c\in T}\mathbb{E}_{x\sim D^c}\tilde{f}(x)^{\mathsf{T}}\tilde{w}_c+\frac{1}{C^2}\sum_{c,c'\in T}\left(\mathbb{E}_{x\sim D^c}\left(\tilde{f}(x)^{\mathsf{T}}\tilde{w}_{c'}\right)\right)^2
=\mathcal{L}_{\mathrm{unif}}(\tilde{f},\widetilde{W}). L ρ T ( f ^ , W ) = − C 2 c ∈ T ∑ E x ∼ D c f ~ ( x ) T w ~ c + C 2 1 c , c ′ ∈ T ∑ ( E x ∼ D c ( f ~ ( x ) T w ~ c ′ ) ) 2 = L unif ( f ~ , W ) .
For a global minimizer under the uniform distribution, this value is − r -r − r , so the transformed pair is a global minimizer for every s > 0 s>0 s > 0 . The stated identity for the logits follows by multiplying the two scaling factors for x ∼ D c x\sim D^c x ∼ D c .
Conversely, let ( f ^ , W ^ ) (\hat{f},\widehat{W}) ( f ^ , W ) be a global minimizer under ρ T \rho_T ρ T and let s > 0 s>0 s > 0 . Define f ~ ( x ) = ρ T ( c ) C s f ^ ( x ) \tilde{f}(x)=\frac{\sqrt{\rho_T(c)C}}{s}\hat{f}(x) f ~ ( x ) = s ρ T ( c ) C f ^ ( x ) for x ∼ D c x\sim D^c x ∼ D c and w ~ c = s ρ T ( c ) C w ^ c \tilde{w}_c=s\sqrt{\rho_T(c)C}\hat{w}_c w ~ c = s ρ T ( c ) C w ^ c for c ∈ T c\in T c ∈ T . Then the identity above gives L u n i f ( f ~ , W ~ ) = L ρ T ( f ^ , W ^ ) = − r \mathcal{L}_{\mathrm{unif}}(\tilde{f},\widetilde{W})=\mathcal{L}_{\rho_T}(\hat{f},\widehat{W})=-r L unif ( f ~ , W ) = L ρ T ( f ^ , W ) = − r . Hence ( f ~ , W ~ ) (\tilde{f},\widetilde{W}) ( f ~ , W ) is a global minimizer under the uniform distribution, and its transformation with this s s s is exactly ( f ^ , W ^ ) (\hat{f},\widehat{W}) ( f ^ , W ) . ■ \blacksquare ■
Proof of Proposition 12
Proof Fix ( x , y ) (x,y) ( x , y ) and write u c = f ( x ) T w c u_c=f(x)^{\mathsf{T}}w_c u c = f ( x ) T w c for c ∈ T c\in T c ∈ T . By the Cauchy–Schwarz inequality, u y ≤ ∥ f ( x ) ∥ ∥ w y ∥ ≤ R 2 ≤ 1 / ρ T ( y ) u_y\leq\lVert f(x)\rVert\lVert w_y\rVert\leq R^2\leq1/\rho_T(y) u y ≤ ∥ f ( x )∥ ∥ w y ∥ ≤ R 2 ≤ 1/ ρ T ( y ) . Since u ↦ − 2 u + ρ T ( y ) u 2 u\mapsto-2u+\rho_T(y)u^2 u ↦ − 2 u + ρ T ( y ) u 2 is strictly decreasing on ( − ∞ , 1 / ρ T ( y ) ] (-\infty,1/\rho_T(y)] ( − ∞ , 1/ ρ T ( y )] , we have
h ( x , y ) = − 2 u y + ∑ c ∈ T ρ T ( c ) u c 2 ≥ − 2 u y + ρ T ( y ) u y 2 ≥ − 2 R 2 + ρ T ( y ) R 4 . h(x,y)=-2u_y+\sum_{c\in T}\rho_T(c)u_c^2\geq-2u_y+\rho_T(y)u_y^2\geq-2R^2+\rho_T(y)R^4. h ( x , y ) = − 2 u y + c ∈ T ∑ ρ T ( c ) u c 2 ≥ − 2 u y + ρ T ( y ) u y 2 ≥ − 2 R 2 + ρ T ( y ) R 4 .
Taking expectations gives E ( x , y ) ∼ D T h ( x , y ) ≥ − 2 R 2 + R 4 ∑ c ∈ T ρ T 2 ( c ) \mathbb{E}_{(x,y)\sim D_T}h(x,y)\geq-2R^2+R^4\sum_{c\in T}\rho_T^2(c) E ( x , y ) ∼ D T h ( x , y ) ≥ − 2 R 2 + R 4 ∑ c ∈ T ρ T 2 ( c ) . Equality holds if and only if, for almost every x x x , u c = 0 u_c=0 u c = 0 for all c ≠ y x c\neq y_x c = y x and u y x = R 2 u_{y_x}=R^2 u y x = R 2 . By the equality condition of the Cauchy–Schwarz inequality, u y x = R 2 u_{y_x}=R^2 u y x = R 2 holds if and only if ∥ w y x ∥ = R \lVert w_{y_x}\rVert=R ∥ w y x ∥ = R and f ( x ) = w y x f(x)=w_{y_x} f ( x ) = w y x , in which case u c = w y x T w c u_c=w_{y_x}^{\mathsf{T}}w_c u c = w y x T w c . Since ρ T ( c ) > 0 \rho_T(c)>0 ρ T ( c ) > 0 for all c ∈ T c\in T c ∈ T , equality therefore holds if and only if { w c / R } c ∈ T \{w_c/R\}_{c\in T} { w c / R } c ∈ T is orthonormal and f ( x ) = w y x f(x)=w_{y_x} f ( x ) = w y x almost surely. Such minimizers exist since d ≥ ∣ T ∣ d\geq|T| d ≥ ∣ T ∣ . As they satisfy ∥ f ( x ) ∥ = ∥ w c ∥ = R \lVert f(x)\rVert=\lVert w_c\rVert=R ∥ f ( x )∥ = ∥ w c ∥ = R , the same characterization and minimum hold under the normalization. ■ \blacksquare ■
The Optimality of Supervised Losses Incurred by Contrastive Learning
Proof of Theorem 13
Proof With the mean classifier, L s u p L_{\mathrm{sup}} L sup is the risk H ( f ) H(f) H ( f ) in Lemma 4. The proof of that lemma shows that f f f minimizes H ( f ) H(f) H ( f ) if and only if f ( x ) = μ y x f(x)=\mu_{y_x} f ( x ) = μ y x almost surely, where ∥ μ c ∥ = R \lVert\mu_c\rVert=R ∥ μ c ∥ = R and μ c T μ c ′ = − R 2 / ( ∣ T ∣ − 1 ) \mu_c^{\mathsf{T}}\mu_{c'}=-R^2/(|T|-1) μ c T μ c ′ = − R 2 / ( ∣ T ∣ − 1 ) for c ≠ c ′ c\neq c' c = c ′ , which is the claim for L s u p L_{\mathrm{sup}} L sup . The case of L s u p ′ L'_{\mathrm{sup}} L sup ′ is proved in Appendix A.4.4. ■ \blacksquare ■
Proof of Corollary 14
Proof Write C = ∣ T ∣ C = \lvert\mathcal{T}\rvert C = ∣ T ∣ , a = C / ( C − 1 ) a = C/(C-1) a = C / ( C − 1 ) , and define
F U ( z ) = ∑ j = 0 k ( k j ) ( C − 1 ) j C k log [ k − j + 1 + j e a z ] , F_U(z) = \sum_{j=0}^{k} \binom{k}{j} \frac{(C-1)^j}{C^k} \log\left[k-j+1+je^{az}\right], F U ( z ) = j = 0 ∑ k ( j k ) C k ( C − 1 ) j log [ k − j + 1 + j e a z ] ,
F S ( z ) = log [ 1 + k e a z ] . F_S(z) = \log\left[1+ke^{az}\right]. F S ( z ) = log [ 1 + k e a z ] .
Use F = F U F=F_U F = F U for L s u p L_{\mathrm{sup}} L sup and F = F S F=F_S F = F S for L s u p ′ L'_{\mathrm{sup}} L sup ′ . Set
D = R 2 − 1 C ∑ c ∥ μ c ∥ 2 + ∥ μ ˉ ∥ 2 , κ = F ′ ( − R 2 ) > 0. D=R^2-\frac{1}{C}\sum_c\lVert\mu_c\rVert^2+\lVert\bar{\mu}\rVert^2,\qquad\kappa=F'(-R^2)>0. D = R 2 − C 1 c ∑ ∥ μ c ∥ 2 + ∥ μ ˉ ∥ 2 , κ = F ′ ( − R 2 ) > 0.
The Jensen inequalities in the proof of Lemma 4 , with all k k k negatives from other classes for L s u p ′ L'_{\mathrm{sup}} L sup ′ , bound the respective risk below by F ( − R 2 + D ) F(-R^2+D) F ( − R 2 + D ) . The feasible simplex ETF attains F ( − R 2 ) F(-R^2) F ( − R 2 ) . Convexity of F F F therefore gives ϵ ≥ κ D \epsilon\geq\kappa D ϵ ≥ κ D . Since
1 C ∑ c E x ∼ D c ∥ f ( x ) − μ c ∥ 2 + ∥ μ ˉ ∥ 2 ≤ D , \frac{1}{C}\sum_c\mathbb{E}_{x\sim\mathcal{D}_c}\lVert f(x)-\mu_c\rVert^2+\lVert\bar{\mu}\rVert^2\leq D, C 1 c ∑ E x ∼ D c ∥ f ( x ) − μ c ∥ 2 + ∥ μ ˉ ∥ 2 ≤ D ,
the first bound follows from κ ≥ e − 2 R 2 / 2 \kappa\geq e^{-2R^2}/2 κ ≥ e − 2 R 2 /2 . Indeed, each denominator in F ′ ( − R 2 ) F'(-R^2) F ′ ( − R 2 ) is at most k + 1 k+1 k + 1 , and j j j has mean k ( C − 1 ) / C k(C-1)/C k ( C − 1 ) / C under the binomial weights of F U F_U F U , so κ ≥ k e − a R 2 / ( k + 1 ) \kappa\geq ke^{-aR^2}/(k+1) κ ≥ k e − a R 2 / ( k + 1 ) for both choices of F F F .
For the Gram matrix, let G = ( μ c T μ c ′ ) c , c ′ G=(\mu_c^\mathsf{T}\mu_{c'})_{c,c'} G = ( μ c T μ c ′ ) c , c ′ and G E T F = a R 2 ( I C − 11 T / C ) G_{\mathrm{ETF}}=aR^2(I_C-\mathbf{1}\mathbf{1}^{\mathsf{T}}/C) G ETF = a R 2 ( I C − 1 1 T / C ) . Write Ψ ( G ) \Psi(G) Ψ ( G ) for the corresponding risk with the anchor representation replaced by its class mean. Jensen’s inequality bounds the original risk below by Ψ ( G ) \Psi(G) Ψ ( G ) , with equality at G E T F G_{\mathrm{ETF}} G ETF . Every matrix on the segment joining G E T F G_{\mathrm{ETF}} G ETF and G G G is positive semidefinite with diagonal at most R 2 R^2 R 2 . For any such matrix, fix a class vector of norm r ≤ R r\leq R r ≤ R in a Gram factorization and write s i ∈ [ − r R , r R ] s_i\in[-rR,rR] s i ∈ [ − r R , r R ] for its sampled inner products, with margins z i = s i − r 2 z_i=s_i-r^2 z i = s i − r 2 . Since Z = e r 2 + ∑ i e s i ≤ ( k + 1 ) e r R Z=e^{r^2}+\sum_i e^{s_i}\leq(k+1)e^{rR} Z = e r 2 + ∑ i e s i ≤ ( k + 1 ) e r R , the softmax weights q 0 = e r 2 / Z q_0=e^{r^2}/Z q 0 = e r 2 / Z and q i = e s i / Z q_i=e^{s_i}/Z q i = e s i / Z satisfy
q 0 q i ≥ e r 2 − 3 r R ( k + 1 ) 2 ≥ e − 2 R 2 ( k + 1 ) 2 , q i q j ≥ e − 4 R 2 ( k + 1 ) 2 . q_0q_i\geq\frac{e^{r^2-3rR}}{(k+1)^2}\geq\frac{e^{-2R^2}}{(k+1)^2},\qquad q_iq_j\geq\frac{e^{-4R^2}}{(k+1)^2}. q 0 q i ≥ ( k + 1 ) 2 e r 2 − 3 r R ≥ ( k + 1 ) 2 e − 2 R 2 , q i q j ≥ ( k + 1 ) 2 e − 4 R 2 .
For ψ ( z ) = log ( 1 + ∑ i e z i ) \psi(z)=\log(1+\sum_i e^{z_i}) ψ ( z ) = log ( 1 + ∑ i e z i ) and the margin direction ξ i = Δ c c i \xi_i=\Delta_{cc_i} ξ i = Δ c c i with Δ \Delta Δ defined below, the identity
ξ T ∇ 2 ψ ( z ) ξ = q 0 ∑ i q i ξ i 2 + ∑ i < j q i q j ( ξ i − ξ j ) 2 \xi^{\mathsf{T}}\nabla^2\psi(z)\xi=q_0\sum_iq_i\xi_i^2+\sum_{i<j}q_iq_j(\xi_i-\xi_j)^2 ξ T ∇ 2 ψ ( z ) ξ = q 0 i ∑ q i ξ i 2 + i < j ∑ q i q j ( ξ i − ξ j ) 2
gives, after i.i.d. negative-class sampling, an expected curvature of at least γ k Var ( ξ 1 ) \gamma_k\operatorname{Var}(\xi_1) γ k Var ( ξ 1 ) , where
γ k = k e − 2 R 2 + k ( k − 1 ) e − 4 R 2 ( k + 1 ) 2 . \gamma_k=\frac{ke^{-2R^2}+k(k-1)e^{-4R^2}}{(k+1)^2}. γ k = ( k + 1 ) 2 k e − 2 R 2 + k ( k − 1 ) e − 4 R 2 .
Here E ( ξ i − ξ j ) 2 = 2 Var ( ξ 1 ) \mathbb{E}(\xi_i-\xi_j)^2=2\operatorname{Var}(\xi_1) E ( ξ i − ξ j ) 2 = 2 Var ( ξ 1 ) and E ξ 1 2 ≥ Var ( ξ 1 ) \mathbb{E}\xi_1^2\geq\operatorname{Var}(\xi_1) E ξ 1 2 ≥ Var ( ξ 1 ) ; the q 0 q_0 q 0 term also covers k = 1 k=1 k = 1 . Set Δ c c ′ = G c c ′ − G c c + a R 2 \Delta_{cc'}=G_{cc'}-G_{cc}+aR^2 Δ c c ′ = G c c ′ − G cc + a R 2 for c ≠ c ′ c\ne c' c = c ′ , and Δ c c = 0 \Delta_{cc}=0 Δ cc = 0 . Let Δ ˉ c = ( C − 1 ) − 1 ∑ c ′ ≠ c Δ c c ′ \bar{\Delta}_c=(C-1)^{-1}\sum_{c'\ne c}\Delta_{cc'} Δ ˉ c = ( C − 1 ) − 1 ∑ c ′ = c Δ c c ′ and V = ∑ c ≠ c ′ ( Δ c c ′ − Δ ˉ c ) 2 V=\sum_{c\ne c'}(\Delta_{cc'}-\bar{\Delta}_c)^2 V = ∑ c = c ′ ( Δ c c ′ − Δ ˉ c ) 2 . Since ∑ c ≠ c ′ Δ c c ′ = C 2 D \sum_{c\ne c'}\Delta_{cc'}=C^2D ∑ c = c ′ Δ c c ′ = C 2 D , symmetry gives the linear term $\kappa D in the expansion of Ψ \Psi Ψ at G E T F G_{\mathrm{ETF}} G ETF . For uniform sampling over all classes, the variance of Δ c c i \Delta_{cc_i} Δ c c i is at least ( C − 1 ) / C (C-1)/C ( C − 1 ) / C times its variance over the other classes. Taylor’s formula along the Gram segment consequently gives, for both sampling schemes,
ϵ ≥ Ψ ( G ) − Ψ ( G E T F ) ≥ κ D + γ k 2 C 2 V . \epsilon\ge\Psi(G)-\Psi(G_{\mathrm{ETF}}) \ge\kappa D+\frac{\gamma_k}{2C^2}V. ϵ ≥ Ψ ( G ) − Ψ ( G ETF ) ≥ κ D + 2 C 2 γ k V .
Finally, let δ c = R 2 − G c c ≥ 0 \delta_c=R^2-G_{cc}\ge0 δ c = R 2 − G cc ≥ 0 and u c = μ c ⊤ μ ˉ u_c=\mu_c^\top\bar{\mu} u c = μ c ⊤ μ ˉ . The off-diagonal row mean of G − G E T F G-G_{\mathrm{ETF}} G − G ETF is ( C u c + δ c ) / ( C − 1 ) (Cu_c+\delta_c)/(C-1) ( C u c + δ c ) / ( C − 1 ) , while ∑ c ( δ c 2 + u c 2 ) ≤ C R 2 D \sum_c(\delta_c^2+u_c^2)\le CR^2D ∑ c ( δ c 2 + u c 2 ) ≤ C R 2 D . Decomposing each row into its mean and centered part and applying Cauchy–Schwarz yields
∥ G − G E T F ∥ F 2 = V + ∑ c δ c 2 + 1 C − 1 ∑ c ( C u c + δ c ) 2 ≤ V + C 2 ( C + 1 ) C − 1 R 2 D . \begin{aligned}
\left\|G-G_{\mathrm{ETF}}\right\|_F^2
=V+\sum_c\delta_c^2+\frac{1}{C-1}\sum_c(Cu_c+\delta_c)^2 \\
&\le V+\frac{C^2(C+1)}{C-1}R^2D.
\end{aligned} ∥ G − G ETF ∥ F 2 = V + c ∑ δ c 2 + C − 1 1 c ∑ ( C u c + δ c ) 2 ≤ V + C − 1 C 2 ( C + 1 ) R 2 D .
Combining these two bounds gives
∥ G − G E T F ∥ F 2 C 2 ≤ max { 2 γ k , C + 1 C − 1 R 2 κ } ϵ . (28) \frac{\left\|G-G_{\mathrm{ETF}}\right\|_F^2}{C^2}
\le\max\left\{\frac{2}{\gamma_k},\frac{C+1}{C-1}\frac{R^2}{\kappa}\right\}\epsilon. \tag*{(28)} C 2 ∥ G − G ETF ∥ F 2 ≤ max { γ k 2 , C − 1 C + 1 κ R 2 } ϵ . (28)
Since γ k ≥ e − 4 R 2 / 4 \gamma_k\ge e^{-4R^2}/4 γ k ≥ e − 4 R 2 /4 and κ ≥ e − a R 2 / 2 \kappa\ge e^{-aR^2}/2 κ ≥ e − a R 2 /2 for both choices of F F F , the coefficient is at most 8 e 4 R 2 8e^{4R^2} 8 e 4 R 2 for all k ≥ 1 k\ge1 k ≥ 1 .
For (18) , choose a class-constant simplex ETF f 0 ∈ F f_0\in\mathcal{F} f 0 ∈ F as the comparator in Theorem 5. At f 0 f_0 f 0 , replacing negatives by their class means is exact. Replacing the positive representation by its target-class mean changes the loss only when y x + ≠ y x y_{x^+}\ne y_x y x + = y x , and then by at most 2 a R 2 \sqrt{2a}R^2 2 a R 2 , since InfoNCE is R R R -Lipschitz in that representation and distinct class means of f 0 f_0 f 0 are at distance 2 a R \sqrt{2a}R 2 a R . Since x + x^+ x + follows the marginal distribution D \mathcal{D} D , f 0 f_0 f 0 is class-constant almost surely for both views. Thus L c o n ( f 0 ) ≤ L s u p ∗ + 2 a R 2 α L_{\mathrm{con}}(f_0)\le L_{\mathrm{sup}}^*+\sqrt{2a}R^2\alpha L con ( f 0 ) ≤ L sup ∗ + 2 a R 2 α , and substitution into Theorem 5 gives (18) . Both stability bounds above apply with ϵ = R Disc ( f ^ ) + Gen M + 2 a R 2 α \epsilon=R\operatorname{Disc}(\hat{f})+\operatorname{Gen}_M+\sqrt{2a}R^2\alpha ϵ = R Disc ( f ^ ) + Gen M + 2 a R 2 α .
Proof of Theorem 15
Proof Let H = [ ρ T ( c ) μ c ] c ∈ T ∈ R d × ∣ T ∣ H=[\sqrt{\rho_{\mathcal{T}}(c)}\mu_c]_{c\in\mathcal{T}}\in\mathbb{R}^{d\times|\mathcal{T}|} H = [ ρ T ( c ) μ c ] c ∈ T ∈ R d × ∣ T ∣ . For the spectral contrastive loss, we have
L s u p = E x ∼ D E { c i } i = 1 k ∼ i . i . d . ρ T [ − 2 f ( x ) ⊤ μ y x + 1 k ∑ i = 1 k ( f ( x ) ⊤ μ c i ) 2 ] = E x ∼ D [ − 2 f ( x ) ⊤ μ y x + E c ∼ ρ T ( f ( x ) ⊤ μ c ) 2 ] ≥ E c ∼ ρ T [ − 2 μ c ⊤ μ c + E c ′ ∼ ρ T ( μ c ⊤ μ c ′ ) 2 ] = − 2 ∑ c ∈ T ρ T ( c ) ∥ μ c ∥ 2 2 + ∑ c ∈ T ∑ c ′ ∈ T ρ T ( c ) ρ T ( c ′ ) ( μ c ⊤ μ c ′ ) 2 = ∥ I − H ⊤ H ∥ F 2 − ∣ T ∣ , \begin{aligned}
L_{\mathrm{sup}}
&=\mathbb{E}_{x\sim\mathcal{D}}\mathbb{E}_{\{c_i\}_{i=1}^k\stackrel{\mathrm{i.i.d.}}{\sim}\rho_{\mathcal{T}}}
\left[-2f(x)^\top\mu_{y_x}+\frac{1}{k}\sum_{i=1}^k\left(f(x)^\top\mu_{c_i}\right)^2\right]\\
&=\mathbb{E}_{x\sim\mathcal{D}}\left[-2f(x)^\top\mu_{y_x}+\mathbb{E}_{c\sim\rho_{\mathcal{T}}}\left(f(x)^\top\mu_c\right)^2\right]\\
&\ge\mathbb{E}_{c\sim\rho_{\mathcal{T}}}\left[-2\mu_c^\top\mu_c+\mathbb{E}_{c'\sim\rho_{\mathcal{T}}}\left(\mu_c^\top\mu_{c'}\right)^2\right]\\
&=-2\sum_{c\in\mathcal{T}}\rho_{\mathcal{T}}(c)\|\mu_c\|_2^2+\sum_{c\in\mathcal{T}}\sum_{c'\in\mathcal{T}}\rho_{\mathcal{T}}(c)\rho_{\mathcal{T}}(c')(\mu_c^\top\mu_{c'})^2\\
&=\left\|I-H^\top H\right\|_F^2-|\mathcal{T}|,
\end{aligned} L sup = E x ∼ D E { c i } i = 1 k ∼ i.i.d. ρ T [ − 2 f ( x ) ⊤ μ y x + k 1 i = 1 ∑ k ( f ( x ) ⊤ μ c i ) 2 ] = E x ∼ D [ − 2 f ( x ) ⊤ μ y x + E c ∼ ρ T ( f ( x ) ⊤ μ c ) 2 ] ≥ E c ∼ ρ T [ − 2 μ c ⊤ μ c + E c ′ ∼ ρ T ( μ c ⊤ μ c ′ ) 2 ] = − 2 c ∈ T ∑ ρ T ( c ) ∥ μ c ∥ 2 2 + c ∈ T ∑ c ′ ∈ T ∑ ρ T ( c ) ρ T ( c ′ ) ( μ c ⊤ μ c ′ ) 2 = I − H ⊤ H F 2 − ∣ T ∣ ,
where I I I is the ∣ T ∣ × ∣ T ∣ |\mathcal{T}| \times|\mathcal{T}| ∣ T ∣ × ∣ T ∣ identity matrix, and the inequality follows from Jensen’s inequality. More precisely, its gap is
L s u p − ( ∥ I − H T H ∥ F 2 − ∣ T ∣ ) = E x ∼ D ∥ H T ( f ( x ) − μ y x ) ∥ 2 . L_{\mathrm{sup}}-\left(\lVert I-H^{\mathsf{T}}H\rVert_{F}^{2}-|\mathcal{T}|\right)=\mathbb{E}_{x\sim D}\lVert H^{\mathsf{T}}(f(x)-\mu_{y_x})\rVert^{2}. L sup − ( ∥ I − H T H ∥ F 2 − ∣ T ∣ ) = E x ∼ D ∥ H T ( f ( x ) − μ y x ) ∥ 2 .
Hence the global minimum is attained by class-constant representations whose means minimize the Gram objective subject to ∥ μ c ∥ ≤ R \lVert\mu_c\rVert\le R ∥ μ c ∥ ≤ R . The feasible set is compact, so such means exist. Equality only requires H T ( f ( x ) − μ y x ) = 0 H^{\mathsf{T}}(f(x)-\mu_{y_x})=0 H T ( f ( x ) − μ y x ) = 0 almost surely; it does not in general imply variability collapse for every minimizer.
Write C = ∣ T ∣ C=|\mathcal{T}| C = ∣ T ∣ , r = min { d , C } r=\min\{d,C\} r = min { d , C } , and G = H T H G=H^{\mathsf{T}}H G = H T H . The Gram objective minus C C C is at least − r -r − r , with equality if and only if G G G is a rank-r r r orthogonal projection. Its diagonal q c = G c c q_c=G_{cc} q c = G cc must satisfy 0 ≤ q c ≤ min { 1 , R 2 ρ T ( c ) } 0\le q_c\le\min\{1,R^2\rho_T(c)\} 0 ≤ q c ≤ min { 1 , R 2 ρ T ( c )} and ∑ c q c = r \sum_c q_c=r ∑ c q c = r , so the stated sum condition is necessary. Conversely, that condition allows a choice of such q c q_c q c . By the Schur–Horn theorem [23 ] , there is a real rank-r r r orthogonal projection with this diagonal. A Gram factorization G = H T H G=H^{\mathsf{T}}H G = H T H in dimension d d d gives class means with ∥ μ c ∥ 2 = q c / ρ T ( c ) ≤ R 2 \lVert\mu_c\rVert^2=q_c/\rho_T(c)\le R^2 ∥ μ c ∥ 2 = q c / ρ T ( c ) ≤ R 2 , proving sufficiency. When C ≤ d C\le d C ≤ d , the rank-C C C projection is I I I . Since the gap above is nonnegative, every global minimizer in this case has such a G G G for its class means. When C > d C>d C > d , such a G G G satisfies ∥ I − G ∥ F 2 = C − d \lVert I-G\rVert_F^2=C-d ∥ I − G ∥ F 2 = C − d , the smallest error of any rank-d d d approximation of I I I , as all singular values of I I I equal one.
For uniform ρ T \rho_T ρ T , let s = tr ( G ) ≤ R 2 s=\operatorname{tr}(G)\le R^2 s = tr ( G ) ≤ R 2 . Since rank ( G ) ≤ r \operatorname{rank}(G)\le r rank ( G ) ≤ r , Cauchy–Schwarz gives ∥ G ∥ F 2 ≥ s 2 / r \lVert G\rVert_F^2\ge s^2/r ∥ G ∥ F 2 ≥ s 2 / r , and the risk is at least − 2 s + s 2 / r -2s+s^2/r − 2 s + s 2 / r . Its minimum over 0 ≤ s ≤ R 2 0\le s\le R^2 0 ≤ s ≤ R 2 is attained at s = min { R 2 , r } s=\min\{R^2,r\} s = min { R 2 , r } . Again by Schur–Horn, choose a rank-r r r orthogonal projection P P P with constant diagonal r / C r/C r / C . Then G = min { R 2 / r , 1 } P G=\min\{R^2/r,1\}P G = min { R 2 / r , 1 } P has diagonal at most R 2 / C R^2/C R 2 / C and attains this lower bound, giving the stated minimum.
Optimality of Supervised Contrastive Cases
The supervised contrastive loss L c o n s u p ( f ) L_{\mathrm{con}}^{\mathrm{sup}}(f) L con sup ( f ) is formulated as
L c o n s u p ( f ) = E c ∼ ρ T E x , x + ∼ i . i . d . D c E { x i − } i = 1 k ∼ i . i . d . D ≠ c ℓ ( f ( x ) , f ( x + ) , { f ( x i − ) } i = 1 k ) . L_{\mathrm{con}}^{\mathrm{sup}}(f)=\mathbb{E}_{c\sim\rho_T}\mathbb{E}_{x,x^+\overset{\mathrm{i.i.d.}}{\sim}D_c}\mathbb{E}_{\{x_i^-\}_{i=1}^{k}\overset{\mathrm{i.i.d.}}{\sim}D^{\ne c}}\ell\left(f(x),f(x^+),\{f(x_i^-)\}_{i=1}^{k}\right). L con sup ( f ) = E c ∼ ρ T E x , x + ∼ i.i.d. D c E { x i − } i = 1 k ∼ i.i.d. D = c ℓ ( f ( x ) , f ( x + ) , { f ( x i − ) } i = 1 k ) .
and its incurred supervised loss is formulated as
L s u p ( D T , W f , h ) = E x ∼ D E { c i } i = 1 k ∼ i . i . d . ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) . L_{\mathrm{sup}}(D_T,W_f,h)=\mathbb{E}_{x\sim D}\mathbb{E}_{\{c_i\}_{i=1}^{k}\overset{\mathrm{i.i.d.}}{\sim}\rho_T}\ell\left(f(x),\mu_{y_x},\{\mu_{c_i}\}_{i=1}^{k}\right). L sup ( D T , W f , h ) = E x ∼ D E { c i } i = 1 k ∼ i.i.d. ρ T ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) .
We now prove the case of L s u p ′ L'_{\mathrm{sup}} L sup ′ in Theorem 13. Proof. Since ρ T \rho_T ρ T is uniform, let C = ∣ T ∣ C = |\mathcal{T}| C = ∣ T ∣ . Then we have μ ˉ = E c ∼ ρ T μ c = 1 C ∑ c ∈ T μ c \bar{\mu} = \mathbb{E}_{c\sim\rho_T}\mu_c = \frac{1}{C}\sum_{c\in\mathcal{T}}\mu_c μ ˉ = E c ∼ ρ T μ c = C 1 ∑ c ∈ T μ c , and
L s u p ′ = E x ∼ D E { c i } i = 1 k ∼ i . i . d . ρ T y x log [ 1 + ∑ i = 1 k exp ( f ( x ) T ( μ c i − μ y x ) ) ] ≥ E x ∼ D log [ 1 + k exp ( f ( x ) T ( C C − 1 μ ˉ − C C − 1 μ y x ) ) ] ≥ 1 C ∑ c ∈ T log [ 1 + k exp ( C C − 1 μ c T ( μ ˉ − μ c ) ) ] ≥ log [ 1 + k exp ( 1 C − 1 ∑ c ∈ T μ c T ( μ ˉ − μ c ) ) ] ≥ log [ 1 + k exp ( − C R 2 C − 1 ) ] . \begin{aligned}
L'_{\mathrm{sup}}=\mathbb{E}_{x\sim D}\mathbb{E}_{\{c_i\}_{i=1}^{k}\overset{\mathrm{i.i.d.}}{\sim}\rho_T^{y_x}}\log\left[1+\sum_{i=1}^{k}\exp\left(f(x)^{\mathsf{T}}(\mu_{c_i}-\mu_{y_x})\right)\right] \\
&\geq\mathbb{E}_{x\sim D}\log\left[1+k\exp\left(f(x)^{\mathsf{T}}\left(\frac{C}{C-1}\bar{\mu}-\frac{C}{C-1}\mu_{y_x}\right)\right)\right] \\
&\geq\frac{1}{C}\sum_{c\in\mathcal{T}}\log\left[1+k\exp\left(\frac{C}{C-1}\mu_c^{\mathsf{T}}(\bar{\mu}-\mu_c)\right)\right] \\
&\geq\log\left[1+k\exp\left(\frac{1}{C-1}\sum_{c\in\mathcal{T}}\mu_c^{\mathsf{T}}(\bar{\mu}-\mu_c)\right)\right] \\
&\geq\log\left[1+k\exp\left(-\frac{CR^2}{C-1}\right)\right].
\end{aligned} L sup ′ = E x ∼ D E { c i } i = 1 k ∼ i.i.d. ρ T y x log [ 1 + i = 1 ∑ k exp ( f ( x ) T ( μ c i − μ y x ) ) ] ≥ E x ∼ D log [ 1 + k exp ( f ( x ) T ( C − 1 C μ ˉ − C − 1 C μ y x ) ) ] ≥ C 1 c ∈ T ∑ log [ 1 + k exp ( C − 1 C μ c T ( μ ˉ − μ c ) ) ] ≥ log [ 1 + k exp ( C − 1 1 c ∈ T ∑ μ c T ( μ ˉ − μ c ) ) ] ≥ log [ 1 + k exp ( − C − 1 C R 2 ) ] .
As in the proof of Lemma 4, equality in the last inequality requires μ ˉ = 0 \bar{\mu}=0 μ ˉ = 0 and ∥ μ c ∥ = R \|\mu_c\|=R ∥ μ c ∥ = R , which imply f ( x ) = μ c f(x)=\mu_c f ( x ) = μ c almost surely under D c D^c D c . The function ( z 1 , … , z k ) ↦ log ( 1 + ∑ i e z i ) (z_1,\ldots,z_k)\mapsto\log(1+\sum_i e^{z_i}) ( z 1 , … , z k ) ↦ log ( 1 + ∑ i e z i ) is strictly convex, so equality in the first inequality requires μ c T μ c ′ \mu_c^{\mathsf{T}}\mu_{c'} μ c T μ c ′ to be constant over c ′ ≠ c c'\ne c c ′ = c . Their sum is − R 2 -R^2 − R 2 , hence each equals − R 2 / ( C − 1 ) -R^2/(C-1) − R 2 / ( C − 1 ) . Conversely, the feasible simplex Gram matrix in the proof of Lemma 4 attains equality throughout, completing the proof. ■
Theorem 21. Consider the supervised spectral loss L s u p = E x ∼ D E { c i } i = 1 k ∼ i . i . d . ρ T y x ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) L_{\mathrm{sup}}=\mathbb{E}_{x\sim D}\mathbb{E}_{\{c_i\}_{i=1}^{k}\overset{\mathrm{i.i.d.}}{\sim}\rho_T^{y_x}}\ell(f(x),\mu_{y_x},\{\mu_{c_i}\}_{i=1}^{k}) L sup = E x ∼ D E { c i } i = 1 k ∼ i.i.d. ρ T y x ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) , that is, ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) = − 2 f ( x ) T μ y x + 1 k ∑ i = 1 k ( f ( x ) T μ c i ) 2 \ell(f(x),\mu_{y_x},\{\mu_{c_i}\}_{i=1}^{k})=-2f(x)^{\mathsf{T}}\mu_{y_x}+\frac{1}{k}\sum_{i=1}^{k}(f(x)^{\mathsf{T}}\mu_{c_i})^2 ℓ ( f ( x ) , μ y x , { μ c i } i = 1 k ) = − 2 f ( x ) T μ y x + k 1 ∑ i = 1 k ( f ( x ) T μ c i ) 2 . Then f f f minimizes L s u p L_{\mathrm{sup}} L sup over all representation functions satisfying ∥ f ( x ) ∥ ≤ R \|f(x)\|\leq R ∥ f ( x ) ∥ ≤ R if and only if f ( x ) = μ y x ∗ f(x)=\mu_{y_x}^{*} f ( x ) = μ y x ∗ almost surely, where { μ c ∗ } c ∈ T \{\mu_c^{*}\}_{c\in\mathcal{T}} { μ c ∗ } c ∈ T minimizes E c ∼ ρ T [ − 2 μ c T μ c + E c ′ ∼ ρ T y x ( μ c T μ c ′ ) 2 ] \mathbb{E}_{c\sim\rho_T}\left[-2\mu_c^{\mathsf{T}}\mu_c+\mathbb{E}_{c'\sim\rho_T^{y_x}}(\mu_c^{\mathsf{T}}\mu_{c'})^2\right] E c ∼ ρ T [ − 2 μ c T μ c + E c ′ ∼ ρ T y x ( μ c T μ c ′ ) 2 ] subject to ∥ μ c ∥ ≤ R \|\mu_c\|\leq R ∥ μ c ∥ ≤ R .
Proof. For the spectral contrastive loss, we have
L s u p = E x ∼ D E { c i } i = 1 k ∼ i . i . d . ρ T y x [ − 2 f ( x ) T μ y x + 1 k ∑ i = 1 k ( f ( x ) T μ c i ) 2 ] = E x ∼ D [ − 2 f ( x ) T μ y x + E c ∼ ρ T y x ( f ( x ) T μ c ) 2 ] ≥ E c ∼ ρ T [ − 2 μ c T μ c + E c ′ ∼ ρ T y x ( μ c T μ c ′ ) 2 ] . \begin{aligned}
L_{\mathrm{sup}}=\mathbb{E}_{x\sim D}\mathbb{E}_{\{c_i\}_{i=1}^{k}\overset{\mathrm{i.i.d.}}{\sim}\rho_T^{y_x}}\left[-2f(x)^{\mathsf{T}}\mu_{y_x}+\frac{1}{k}\sum_{i=1}^{k}(f(x)^{\mathsf{T}}\mu_{c_i})^2\right] \\
&=\mathbb{E}_{x\sim D}\left[-2f(x)^{\mathsf{T}}\mu_{y_x}+\mathbb{E}_{c\sim\rho_T^{y_x}}(f(x)^{\mathsf{T}}\mu_c)^2\right] \\
&\geq\mathbb{E}_{c\sim\rho_T}\left[-2\mu_c^{\mathsf{T}}\mu_c+\mathbb{E}_{c'\sim\rho_T^{y_x}}(\mu_c^{\mathsf{T}}\mu_{c'})^2\right].
\end{aligned} L sup = E x ∼ D E { c i } i = 1 k ∼ i.i.d. ρ T y x [ − 2 f ( x ) T μ y x + k 1 i = 1 ∑ k ( f ( x ) T μ c i ) 2 ] = E x ∼ D [ − 2 f ( x ) T μ y x + E c ∼ ρ T y x ( f ( x ) T μ c ) 2 ] ≥ E c ∼ ρ T [ − 2 μ c T μ c + E c ′ ∼ ρ T y x ( μ c T μ c ′ ) 2 ] .
Denote the last expression by Q ( { μ c } ) Q(\{\mu_c\}) Q ({ μ c }) . It has a minimizer on the compact set ∥ μ c ∥ ≤ R \|\mu_c\|\leq R ∥ μ c ∥ ≤ R , and the corresponding class-constant representations attain the lower bound. Moreover,
L s u p − Q ( { μ c } ) = E c ∼ ρ T E x ∼ D c E c ′ ∼ ρ T y x [ ( ( f ( x ) − μ c ) T μ c ′ ) 2 ] . L_{\mathrm{sup}}-Q(\{\mu_c\})=\mathbb{E}_{c\sim\rho_T}\mathbb{E}_{x\sim D^c}\mathbb{E}_{c'\sim\rho_T^{y_x}}\left[((f(x)-\mu_c)^{\mathsf{T}}\mu_{c'})^2\right]. L sup − Q ({ μ c }) = E c ∼ ρ T E x ∼ D c E c ′ ∼ ρ T y x [ (( f ( x ) − μ c ) T μ c ′ ) 2 ] .
Any minimizer must therefore minimize Q Q Q and satisfy ( f ( x ) − μ c ) T μ c ′ = 0 (f(x)-\mu_c)^{\mathsf{T}}\mu_{c'}=0 ( f ( x ) − μ c ) T μ c ′ = 0 almost surely for every c ′ ≠ c c'\ne c c ′ = c . If a class has nonzero within-class variance, then ∥ μ c ∥ < R \|\mu_c\|<R ∥ μ c ∥ < R and there exists a nonzero v v v orthogonal to all μ c ′ \mu_{c'} μ c ′ , c ′ ≠ c c'\ne c c ′ = c . Replacing μ c \mu_c μ c by μ c + s v \mu_c+sv μ c + s v for sufficiently small s s s preserves feasibility and all cross-class inner products. Choosing the sign of s s s so that 2 s μ c T v + s 2 ∥ v ∥ 2 > 0 2s\mu_c^{\mathsf{T}}v+s^2\|v\|^2>0 2 s μ c T v + s 2 ∥ v ∥ 2 > 0 strictly decreases Q Q Q through its term − 2 ρ T ( c ) ∥ μ c ∥ 2 -2\rho_T(c)\|\mu_c\|^2 − 2 ρ T ( c ) ∥ μ c ∥ 2 , a contradiction. Thus every minimizer is class-constant almost surely, proving both directions. ■
One Negative Sample Case
To better understand the supervised loss incurred by contrastive learning, we also explore the special case where only one negative sample is used (i.e., k = 1 k=1 k = 1 ). Negative sampling is also used in Word2Vec [36 ] . Here, we consider the contrastive objective with one negative sample, defined as follows:
L c o n ( f , D ; ℓ ) = E x , x + ∼ D p o s x − ∼ D n e g ℓ ( f ( x ) , f ( x + ) , f ( x − ) ) . (29) L_{\mathrm{con}}(f,\mathcal{D};\ell)=\mathbb{E}_{\substack{x,x^+\sim\mathcal{D}_{\mathrm{pos}}\\x^-\sim\mathcal{D}_{\mathrm{neg}}}}\ell(f(x),f(x^+),f(x^-)). \tag*{(29)} L con ( f , D ; ℓ ) = E x , x + ∼ D pos x − ∼ D neg ℓ ( f ( x ) , f ( x + ) , f ( x − )) . (29)
In this case, the incurred loss h h h in Theorem 2 can be precisely characterized when class collision results in a constant loss value. Let π = E c , c ′ ∼ i . i . d . ρ T I ( c = c ′ ) \pi=\mathbb{E}_{c,c'\mathrel{\overset{\mathrm{i.i.d.}}{\sim}}\rho_T}\mathbb{I}(c=c') π = E c , c ′ ∼ i.i.d. ρ T I ( c = c ′ ) . For losses satisfying ℓ ( v , u , u ) = ℓ ( 0 ) \ell(v,u,u)=\ell(0) ℓ ( v , u , u ) = ℓ ( 0 ) for all ∥ v ∥ , ∥ u ∥ ≤ R \lVert v\rVert,\lVert u\rVert\le R ∥ v ∥ , ∥ u ∥ ≤ R , where ℓ ( 0 ) \ell(0) ℓ ( 0 ) is constant, we can derive a similar bound to that of Saunshi et al. [45 ] without relying on the assumption of conditional independence of positive pairs.
Proposition 22. Under the notation and conditions in Theorem 2, suppose k = 1 k=1 k = 1 and ℓ ( v , u , u ) = ℓ ( 0 ) \ell(v,u,u)=\ell(0) ℓ ( v , u , u ) = ℓ ( 0 ) is constant for ∥ v ∥ , ∥ u ∥ ≤ R \lVert v\rVert,\lVert u\rVert\le R ∥ v ∥ , ∥ u ∥ ≤ R . Then, for all f ∈ F f\in\mathcal{F} f ∈ F , there exist a linear classifier W ∈ R ∣ T ∣ × d W\in\mathbb{R}^{|\mathcal{T}|\times d} W ∈ R ∣ T ∣ × d and a supervised loss h h h such that
L s u p ( D T , W f , h ) ≤ L c o n ( f ) + η ⋅ Disc ( f ) − π ⋅ ℓ ( 0 ) , (30) L_{\mathrm{sup}}(\mathcal{D}_T,Wf,h)\le L_{\mathrm{con}}(f)+\eta\cdot\operatorname{Disc}(f)-\pi\cdot\ell(0), \tag*{(30)} L sup ( D T , W f , h ) ≤ L con ( f ) + η ⋅ Disc ( f ) − π ⋅ ℓ ( 0 ) , (30) where the incurred loss h ( w y T f ( x ) , { w c T f ( x ) } c ≠ y ) = ( 1 − ρ T ( y ) ) E c ∼ ρ T y ℓ ( f ( x ) , w y , w c ) h(w_y^\mathsf{T}f(x),\{w_c^\mathsf{T}f(x)\}_{c\ne y})=(1-\rho_T(y))\mathbb{E}_{c\sim\rho_T^y}\ell(f(x),w_y,w_c) h ( w y T f ( x ) , { w c T f ( x ) } c = y ) = ( 1 − ρ T ( y )) E c ∼ ρ T y ℓ ( f ( x ) , w y , w c ) .
Proof. Let w c = μ c = E x ∼ D c f ( x ) w_c=\mu_c=\mathbb{E}_{x\sim\mathcal{D}^c}f(x) w c = μ c = E x ∼ D c f ( x ) . Splitting the mean-classifier loss according to whether the negative class equals the anchor class gives
E x ∼ D E c ∼ ρ T ℓ ( f ( x ) , μ y x , μ c ) = E x ∼ D [ ( 1 − ρ T ( y x ) ) E c ∼ ρ T y x ℓ ( f ( x ) , μ y x , μ c ) + ρ T ( y x ) ℓ ( 0 ) ] = L s u p ( D T , W f , h ) + π ℓ ( 0 ) . \begin{aligned}
\mathbb{E}_{x\sim\mathcal{D}}\mathbb{E}_{c\sim\rho_T}\ell(f(x),\mu_{y_x},\mu_c)
=\mathbb{E}_{x\sim\mathcal{D}}\left[(1-\rho_T(y_x))\mathbb{E}_{c\sim\rho_T^{y_x}}\ell(f(x),\mu_{y_x},\mu_c)+\rho_T(y_x)\ell(0)\right] \\
&=L_{\mathrm{sup}}(\mathcal{D}_T,Wf,h)+\pi\ell(0).
\end{aligned} E x ∼ D E c ∼ ρ T ℓ ( f ( x ) , μ y x , μ c ) = E x ∼ D [ ( 1 − ρ T ( y x )) E c ∼ ρ T y x ℓ ( f ( x ) , μ y x , μ c ) + ρ T ( y x ) ℓ ( 0 ) ] = L sup ( D T , W f , h ) + π ℓ ( 0 ) .
Theorem 2 bounds the left-hand side by L c o n ( f ) + η Disc ( f ) L_{\mathrm{con}}(f)+\eta\operatorname{Disc}(f) L con ( f ) + η Disc ( f ) , completing the proof. ■
Multi-Class Binary Cross Entropy. For the InfoNCE loss with only one negative sample, we have the incurred loss
h ( W f ( x ) , y ) = ( 1 − ρ T ( y ) ) E c ∼ ρ T y log [ 1 + e f ( x ) T ( w c − w y ) ] , (31) h(Wf(x),y)=(1-\rho_T(y))\mathbb{E}_{c\sim\rho_T^y}\log\left[1+e^{f(x)^{\mathsf{T}}(w_c-w_y)}\right], \tag*{(31)} h ( W f ( x ) , y ) = ( 1 − ρ T ( y )) E c ∼ ρ T y log [ 1 + e f ( x ) T ( w c − w y ) ] , (31)
which can be viewed as a multi-class binary cross entropy that trains the binary classifiers { w y − w c } c ≠ y \{w_y-w_c\}_{c\ne y} { w y − w c } c = y with weighted logistic losses for each sample x x x drawn from D y \mathcal{D}^y D y . Taking ℓ ( 0 ) = log 2 \ell(0)=\log2 ℓ ( 0 ) = log 2 in Proposition 22 gives the deterministic InfoNCE bound L s u p ( D T , W f , h ) ≤ L c o n ( f ) + η Disc ( f ) − π log 2 L_{\mathrm{sup}}(\mathcal{D}_T,Wf,h)\le L_{\mathrm{con}}(f)+\eta\operatorname{Disc}(f)-\pi\log2 L sup ( D T , W f , h ) ≤ L con ( f ) + η Disc ( f ) − π log 2 for the loss in Equation (31) .
For a direct classification guarantee, let h 1 h_1 h 1 denote the k = 1 k=1 k = 1 InfoNCE-incurred loss in Theorem 2 , including target-class negatives, and set p min = min c ∈ T ρ T ( c ) > 0 p_{\min}=\min_{c\in\mathcal{T}}\rho_T(c)>0 p m i n = min c ∈ T ρ T ( c ) > 0 . With any fixed rule for breaking ties, the classification error under D T \mathcal{D}_T D T satisfies
P ( x , y ) ∼ D T [ arg max c ∈ T w c T f ( x ) ≠ y ] ≤ L s u p ( D T , W f , h 1 ) − π log 2 p min log 2 . (32) \mathbb{P}_{(x,y)\sim\mathcal{D}_T}\left[\underset{c\in\mathcal{T}}{\arg\max}\ w_c^{\mathsf{T}}f(x)\ne y\right]\le\frac{L_{\mathrm{sup}}(\mathcal{D}_T,Wf,h_1)-\pi\log2}{p_{\min}\log2}. \tag*{(32)} P ( x , y ) ∼ D T [ c ∈ T arg max w c T f ( x ) = y ] ≤ p m i n log 2 L sup ( D T , W f , h 1 ) − π log 2 . (32)
This is the case k = 1 k=1 k = 1 of the first bound in Corollary 6 , since then E y ∼ ρ T h 0 ( y ) = π log 2 \mathbb{E}_{y\sim\rho_T}h_0(y)=\pi\log2 E y ∼ ρ T h 0 ( y ) = π log 2 and ω 1 ( y ) = log 2 ⋅ min c ≠ y ρ T ( c ) ≥ p min log 2 \omega_1(y)=\log2\cdot\min_{c\ne y}\rho_T(c)\ge p_{\min}\log2 ω 1 ( y ) = log 2 ⋅ min c = y ρ T ( c ) ≥ p m i n log 2 , and that corollary also bounds its numerator for the mean classifier of f f f .
Experiments
Experimental Details
In this section, we present the training details and experimental results across various tasks, encompassing unsupervised contrastive learning and supervised learning on CIFAR-10, CIFAR-100 [29 ] , and ImageNet-100 (the first 100 classes of ImageNet) [8 ] . The chosen network architectures are ResNet-18 [19 ] for CIFAR-10/CIFAR-100, and ResNet-50 for ImageNet-100. All models are trained for 200 epochs using the SGD optimizer and a cosine decay learning rate schedule, with an initial learning rate of 0.2, a batch size of 512, and a weight decay of 5e-4.
More Experimental Results
More Results on the Relaxed K-Means Loss. We conduct experiments with independent runs and report standard deviations to illustrate the performance of the relaxed k-means loss. For Table 3 , we run 3 trials with random seeds (0, 1, 2) for each λ ∈ { 0 , 0.01 , 0.02 , 0.05 , 0.1 , 0.2 , 0.5 , 1 } \lambda\in\{0, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1\} λ ∈ { 0 , 0.01 , 0.02 , 0.05 , 0.1 , 0.2 , 0.5 , 1 } . As is evident in the table, the performance in linear probing deteriorates when λ \lambda λ is too large, suggesting inherent limitations of the relaxed k-means loss. This could be attributed to the fact that it only focuses on reducing distances between representations within a specific range rather than rigorously shrinking the distance to cluster centers. Consequently, this relaxation would inevitably cause representations of semantically inconsistent samples to become close, particularly in the early stage of training. Despite these limitations, we still observe an improvement, particularly on ImageNet-100.
Table 3. Linear probing accuracies (%) on CIFAR-10, CIFAR-100, and ImageNet-100 using unsupervised contrastive learning with the InfoNCE loss and the relaxed k-means loss, i.e., L ^ c o n + λ ⋅ L ^ k - m e a n s ( f ) \widehat{L}_{\mathrm{con}} + \lambda\cdot\widehat{L}_{\mathrm{k\text{-}means}}(f) L con + λ ⋅ L k - means ( f ) , where λ ∈ { 0 , 0.01 , 0.02 , 0.05 , 0.1 , 0.2 , 0.5 , 1 } \lambda\in\{0, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1\} λ ∈ { 0 , 0.01 , 0.02 , 0.05 , 0.1 , 0.2 , 0.5 , 1 } and τ = 0.5 \tau= 0.5 τ = 0.5 .
Validation of Theorem 11
In the proof of Theorem 11 , a global minimizer is obtained by minimizing
∥ ( ρ T ( c ) μ c ) c ∈ T ⊤ ( ρ T ( c ) w c ) c ∈ T − I ∥ F 2 \left\| \left(\sqrt{\rho_T(c)}\mu_c\right)_{c\in T}^{\top}\left(\sqrt{\rho_T(c)}w_c\right)_{c\in T}-I \right\|_F^2 ( ρ T ( c ) μ c ) c ∈ T ⊤ ( ρ T ( c ) w c ) c ∈ T − I F 2
over class means and classifier weights, where μ c = E x ∼ D c f ( x ) \mu_c=\mathbb{E}_{x\sim D_c}f(x) μ c = E x ∼ D c f ( x ) . For s > 0 s>0 s > 0 , let μ ^ c = s ∣ T ∣ ρ T ( c ) μ c \hat{\mu}_c=s\sqrt{|T|\rho_T(c)}\mu_c μ ^ c = s ∣ T ∣ ρ T ( c ) μ c and w ^ c = 1 s ∣ T ∣ ρ T ( c ) w c \hat{w}_c=\frac{1}{s}\sqrt{|T|\rho_T(c)}w_c w ^ c = s 1 ∣ T ∣ ρ T ( c ) w c . The matrix objective then equals
∥ ( 1 ∣ T ∣ μ ^ c ) c ∈ T ⊤ ( 1 ∣ T ∣ w ^ c ) c ∈ T − I ∥ F 2 \left\| \left(\frac{1}{\sqrt{|T|}}\hat{\mu}_c\right)_{c\in T}^{\top}\left(\frac{1}{\sqrt{|T|}}\hat{w}_c\right)_{c\in T}-I \right\|_F^2 ( ∣ T ∣ 1 μ ^ c ) c ∈ T ⊤ ( ∣ T ∣ 1 w ^ c ) c ∈ T − I F 2
for the class-balanced case.
Both distributions attain the same minimum, so this scaling maps corresponding global minimizers while preserving cosine similarities between their nonzero features and classifier weights.
To illustrate this point, we conduct experiments on long-tailed CIFAR-10 using ResNet-18 with a feature dimension of 512, and ∣ T ∣ = 10 |T|=10 ∣ T ∣ = 10 . Since d ≥ ∣ T ∣ d\geq|T| d ≥ ∣ T ∣ , we can derive that the global minimizer of
∥ ( ρ T ( c ) μ c ) c ∈ T ⊤ ( ρ T ( c ) w c ) c ∈ T − I ∥ F 2 \left\| \left(\sqrt{\rho_T(c)}\mu_c\right)_{c\in T}^{\top}\left(\sqrt{\rho_T(c)}w_c\right)_{c\in T}-I \right\|_F^2 ( ρ T ( c ) μ c ) c ∈ T ⊤ ( ρ T ( c ) w c ) c ∈ T − I F 2
satisfies μ c ⊤ w c = 1 ρ T ( c ) \mu_c^{\top}w_c=\frac{1}{\rho_T(c)} μ c ⊤ w c = ρ T ( c ) 1 , μ c ⊤ w c ′ = 0 \mu_c^{\top}w_{c'}=0 μ c ⊤ w c ′ = 0 for c ≠ c ′ c\ne c' c = c ′ . The results are presented in Table 4 . As observed, the logits μ c ⊤ w c \mu_c^{\top}w_c μ c ⊤ w c of the representation model roughly align with 1 ρ T ( c ) \frac{1}{\rho_T(c)} ρ T ( c ) 1 across the board.
Table 4. Illustration of 1 ρ T ( c ) \frac{1}{\rho^{T}(c)} ρ T ( c ) 1 and μ c T w c \mu_c^{T}w_c μ c T w c on long-tailed CIFAR-10 with an imbalance ratio of 10.