T OWARDS THE G ENERALIZATION OF C ONTRASTIVE S ELF -S UPERVISED L EARNING
A BSTRACT
Recently, self-supervised learning has attracted great attention, since it only requires unlabeled data for model training.
Contrastive learning is one popular method for self-supervised learning and has achieved promising empirical performance.
However, the theoretical understanding of its generalization ability is still limited.
To this end, we define a kind of ( σ, δ ) -measure to mathematically quantify the data augmentation, and then provide an upper bound of the downstream classification error rate based on the measure.
It reveals that the generalization ability of contrastive self-supervised learning is related to three key factors: alignment of positive samples, divergence of class centers, and concentration of augmented data.
The first two factors are properties of learned representations, while the third one is determined by pre-defined data augmentation.
We further investigate two canonical contrastive losses, InfoNCE and cross-correlation, to show how they provably achieve the first two factors.
Moreover, we conduct experiments to study the third factor, and observe a strong correlation between downstream performance and the concentration of augmented data.
I NTRODUCTION
Contrastive Self-Supervised Learning (SSL) has attracted great attention for its fantastic data efficiency and generalization ability in computer vision (He et al., 2020;
Chen et al., 2020a;b; Grill et al., 2020; Chen & He, 2021; Zbontar et al., 2021) and natural language processing (Fang et al., 2020; Wu et al., 2020; Giorgi et al., 2020; Gao et al., 2021; Yan et al., 2021).
It learns the representation through a large number of unlabeled data and manually designed supervision signals (i.e., regarding the augmented views of a data sample as positive samples).
The model is updated by encouraging the features of positive samples close to each other.
To overcome the feature collapse issue, various losses (e.g., InfoNCE (Chen et al., 2020a; He et al., 2020) and cross-correlation (Zbontar et al., 2021)) and training strategies (e.g., stop gradient (Grill et al., 2020; Chen & He, 2021)) are proposed.
In spite of the empirical success of contrastive SSL in terms of their generalization ability on downstream tasks, the theoretical understanding is still limited.
Arora et al.
(2019) propose a theoretical framework to show the provable downstream performance of contrastive SSL based on the InfoNCE loss.
However, their results rely on the assumption that positive samples are drawn from the same latent class, instead of the augmented views of a data point as in practice.
Wang &
Isola (2020) propose alignment and uniformity to explain the downstream performance, but they are empirical indicators and lack of theoretical generalization guarantees.
Both of the above works avoid characterizing the important role of data augmentation, which is the key to the success of contrastive
SSL, since the only human knowledge is injected via data augmentation.
Recently, HaoChen et al.
(2021) propose to model the augmented data as a graph and study contrastive SSL from a matrix decomposition perspective, but it is only applicable to their own spectral contrastive loss.
Besides the limitations of existing contrastive SSL theories, there are also some interesting empirical observations that have not been unraveled theoretically yet.
For example, why does the richer data [Figure] augmentation lead to the more clustered structure in the embedding space (Figure 1) as well as the better downstream performance (also observed by Chen et al.
(2020a))?
Why is aligning positive samples (augmented from the “same data point”) able to gather the samples from the “same latent class” into a cluster (Figure 1c)?
More interestingly, decorrelating components of representation like
Barlow Twins (Zbontar et al., 2021) does not directly optimize the geometry of embedding space, but it still results in the clustered structure.
Why is this?
[Figure]
In this paper, we focus on exploring the generalization ability of contrastive SSL provably , which can explain the above interesting observations.
We start with understanding the role of data augmentation in contrastive SSL.
Intuitively, samples from the same latent class are likely to have similar augmented views, which are mapped to the close locations in the embedding space.
Since the augmented views of each sample are encouraged to be clustered in the embedding space by contrastive learning, different samples from the same latent class tend to be pulled closer.
As an example, let’s consider two images of dogs with different backgrounds (Figure 2).
If we augment them with transformation “crop”, we may get two similar views (dog heads), whose representations (gray points in the embedding space) are close.
As the augmented views of each dog image are enforced to be close in the embedding space due to the objective of contrastive learning, the representations of two dog images (green and blue points) will be pulled closer to their augmented views (gray points).
In this way, aligning positive samples is able to gather samples from the same class, and thus results in the clustered embedding space.
Following the above intuition, we define the augmented distance between two samples as the minimum distance between their augmented views, and further introduce the ( σ, δ ) -augmentation to measure the concentration of augmented data, i.e., for each latent class, the proportion of samples located in a ball with diameter δ (w.r.t.
the augmented distance) is larger than σ .
With the mathematical description of data augmentation settled, we then prove an upper bound of downstream classification error rate in Section 3.
It reveals that the generalization of contrastive SSL is related to three key factors.
The first one is alignment of positive samples, which is a common objective that contrastive learning algorithms aim to optimize.
The second one is divergence of class centers, which prevents the collapse of representation.
The third factor is concentration of augmented data, i.e., a sharper concentration of augmented data indicates a better generalization error bound.
We remark that the first two factors are properties of representations that can be optimized during the learning process. However, the third factor is determined by pre-defined data augmentation and is independent of the learning process.
Thus, data augmentation plays a crucial role in contrastive SSL.
We then study the above three factors in more depth.
In Section 4, we rigorously prove that not only the InfoNCE loss but also the cross-correlation loss (which does not directly optimize the geometry of embedding space) can satisfy the first two factors.
For the third factor, we conduct various experiments on the real-world datasets and observe that the downstream performance of contrastive SSL is highly correlated to the concentration of augmented data in Section 5.
In summary, our contributions include: 1) proposing a novel ( σ, δ ) -measure to quantify data augmentation; 2) presenting a theoretical framework for contrastive SSL that highlights alignment, divergence, and concentration as key factors for generalization ability; provably verifying that not only the InfoNCE loss but also the cross-correlation loss satisfy alignment and divergence;
4) showing a strong correlation between downstream performance and concentration of augmented data.
R ELATED W ORK
Algorithms of Contrastive SSL.
Early works such as MoCo (He et al., 2020) and SimCLR (Chen et al., 2020a), use the InfoNCE loss to pull the positive samples close while enforcing them away from the negative samples in the embedding space.
These methods require large batch sizes (Chen et al., 2020a), memory banks (He et al., 2020), or carefully designed negative sampling strategies (Hu et al., 2021).
To obviate these, some recent works get rid of negative samples and prevent representation collapse by cross-correlation loss (Zbontar et al., 2021;
Bardes et al., 2021) or training strategies (Grill et al., 2020; Chen & He, 2021).
In this paper, we mainly study the effectiveness of the InfoNCE loss and the cross-correlation loss, and do not enter the discussion of training strategies.
Theoretical Understandings of Contrastive SSL.
Most theoretical analysis is based on the InfoNCE loss, and lack of understanding of recently proposed cross-correlation loss (Zbontar et al., 2021).
Early works understand the InfoNCE loss based on maximizing the mutual information (MI) between positive samples (Oord et al., 2018; Bachman et al., 2019;
Hjelm et al., 2018; Tian et al., 2019; 2020; Tschannen et al., 2019).
However, a rigorous relationship between mutual information and downstream performance has not been established.
Besides, Arora et al.
(2019) directly analyze the generalization of InfoNCE loss based on the assumption that positive samples are drawn from the same latent classes, which is different from practical algorithms.
Ash et al.
(2021) study the role of negative samples and show an interesting collision-coverage trade-off theoretically.
HaoChen et al.
(2021) study contrastive SSL from a matrix decomposition perspective, but it is only applicable to their spectral contrastive loss.
The behavior of InfoNCE is also studied from the perspective of alignment and uniformity (Wang & Isola, 2020), sparse coding model (Wen & Li, 2021), the expansion assumption (Wei et al., 2020), stochastic neighbor embedding (Hu et al., 2022), and augmentation robustness (Zhao et al., 2023).
P ROBLEM F ORMULATION
Given a number of unlabeled training data i.i.d.
drawn from an unknown distribution, each sample belongs to one of K latent classes C 1 , C 2 , . .
, C K .
Based on an augmentation set A , the set of potential positive samples generated from a data point x is denoted as A ( x ) .
We assume that x ∈ A ( x ) for any x , and samples from different latent classes never transform into the same augmented sample, i.e., A ( C k ) ∩ A ( C ℓ ) = ∅ for any k ̸ = ℓ .
Notation ∥ · ∥ in this paper stands for ℓ 2 -norm or Frobenius norm for vectors and matrices, respectively.
Contrastive SSL aims to learn an encoder f , such that positive samples are closely aligned.
In order to make the samples from different latent classes far away from each other, some methods such as (Chen et al., 2020a; He et al., 2020) use the InfoNCE loss 1 to push away negative pairs, formulated as
[Equation]
where x , x ′ are two random data points.
Some other methods such as Barlow Twins (Zbontar et al., 2021) use the cross-correlation loss to decorrelate the components of representation, formulated as L Cross-Corr = d [Equation] (cid:88)
[Equation]
̸
[Equation]
j F [Equation] where F ij = E x E x 1 , x 2 ∈ A ( x ) [ f i ( x 1 ) f j ( x 2 )] , d is the dimension of encoder f , and encoder f is normalized as E x E x ′ ∈ A ( x ) [ f i ( x ′ ) 2 ]
= 1 for each dimension i .
The standard evaluation of contrastive SSL is to train a linear classifier over the learned representation using labeled data and regard its performance as the indicator.
To simplify the analysis, we instead consider a non-parametric classifier – nearest neighbor (NN) classifier:
[Equation]
where µ k :=
E x ∈ C k E x ′ ∈
A ( x ) [ f ( x ′ )] is the center of class C k .
In fact, the NN classifier is a special case of linear classifier, since it can be reformulated as G f ( x ) =
arg max k ∈ [ K ] ( Wf ( x ) + b ) k , where the k -th row of W is µ k and b k = − 12 ∥ µ k ∥ 2 (See Appendix E).
Therefore, the directly learned linear classifier used in practice should perform better than the NN classifier.
In this paper, we use the classification error rate to quantify the performance of G f , formulated as
[Equation]
Our goal is to study why contrastive SSL is able to achieve a small Err( G f ) .
G ENERALIZATION G UARANTEE OF C ONTRASTIVE SSL
Based on the NN classifier, if the samples are well clustered by latent classes in the embedding space, the error rate Err( G f ) should be small.
Thus, one expects to have a small intra-class distance
E x 1 , x 2 ∈ C k ∥ f ( x 1 ) − f ( x 2 ) ∥ 2 for an encoder f learned by contrastive learning.
However, contrastive algorithms can only control the alignment of positive samples E x 1 , x 2 ∈ A ( x ) ∥
f ( x 1 ) − f ( x 2 ) ∥ 2 .
To bridge the gap between them, we need to investigate the role of data augmentation.
Motivated by Figure 2 introduced in Section 1, for a given augmentation set A , we define the augmented distance between two samples as the minimum distance between their augmented views:
[Equation]
For the dog images in Figure 2 as an example, even though their pixel-level differences are significant, their semantic meanings are similar.
Meanwhile, they also have a small augmented distance.
Thus, the proposed augmented distance can partially capture the semantic distance.
Based on the augmented distance, we now introduce the ( σ, δ ) -augmentation to measure the concentration of augmented data.
Definition 1 ( ( σ, δ ) -Augmentation) .
The augmentation set A is called a ( σ, δ ) -augmentation, if for each class C k , there exists a subset C 0 k ⊆ C k (called a main part of C k ),
such that both P [ x ∈ C 0 k ] ≥ σ P [ x ∈ C k ] where σ ∈ (0 , 1] and sup x 1 , x 2 ∈ C 0 k
d
A
x 1 , x 2 ) ≤ δ hold.
In other words, the main-part samples locate in a ball with diameter δ (w.r.t.
the augmented distance) and its proportion is larger than σ .
Larger σ and smaller δ indicate the sharper concentration of augmented data.
For any A ′ ⊇ A with richer augmentations, one can verify that d A ′ ( x 1 , x 2 ) ≤
d A ( x 1 , x 2 ) for any x 1 , x 2 .
Therefore, richer data augmentations lead to sharper concentration as δ gets smaller.
With Definition 1, our analysis will focus on the samples in the main parts with good alignment, i.e., ( C 01 ∪ · · · ∪ C 0 K ) ∩ S ε , where S ε := { x ∈ ∪ Kk =1 C k : ∀ x 1 , x 2 ∈
A ( x ) , ∥ f
( x 1 ) − f ( x 2 ) ∥ ≤ ε } is the set of samples with ε -close representations among augmented data.
Furthermore, we let R ε := P (cid:2) S ε (cid:3) , which is provably small with good alignment (see Theorem 2).
Lemma 3.1.
For a ( σ, δ ) -augmentation with main part C 0 k of each class C k , if all samples belonging to ( C 01 ∪ · · · ∪ C 0 K ) ∩ S ε can be correctly classified by a classifier G , then its classification error rate Err( G ) is upper bounded by (1 − σ ) + R ε .
The proof is deferred to the appendix.
The above lemma presents a simple sufficient condition to guarantee the generalization ability on downstream tasks.
Based on it, we need to further explore when samples in ( C 01 ∪ · · · ∪ C 0 K ) ∩ S ε can be all correctly classified by the NN classifier.
We assume that encoder f is normalized by ∥ f ∥ = r , and it is L -Lipschitz continuity, i.e., for any x 1 , x 2 , ∥ f ( x 1 ) − f ( x 2 ) ∥
≤ L ∥ x 1 − x 2 ∥ .
We let p k :=
P [ x ∈ C k ] for any k ∈
[ K ] .
Lemma 3.2.
Given a ( σ, δ ) -augmentation used in contrastive SSL, for any ℓ ∈ [ K ] , if µ ⊤ ℓ µ k < r 2 (cid:16) 1 − ρ ℓ ( σ, δ, ε ) − (cid:112) 2 ρ ℓ ( σ, δ, ε ) − ∆ µ 2 (cid:17) holds for all k ̸ = ℓ , then every sample x ∈ C 0 ℓ ∩ S ε can be correctly classified by the NN classifier G f , where ρ ℓ ( σ, δ, ε ) =
2(1 − σ ) + R ε p ℓ + σ (cid:0) Lδr + 2 εr (cid:1) and ∆ µ = 1 − min k ∈
[ K ] ∥ µ k ∥ 2 /r 2 .
With Lemma 3.1 and 3.2, we can directly obtain the generalization guarantee of contrastive SSL:
Theorem 1.
Given a ( σ, δ ) -augmentation used in contrastive SSL, if
[Equation]
holds for any pair of ( ℓ, k ) with ℓ ̸
= k , then the downstream error rate of NN classifier G f
[Equation]
where ρ max ( σ, δ, ε )
=
2(1 − σ )
+
[Equation]
The proof is deferred to the appendix.
To better understand the above theorem, let us first consider a simple case that any two samples from the latent same class at least own a same augmented view ( σ = 1 , δ = 0 ), and the positive samples are perfectly aligned after contrastive learning ( ε = 0 , R ε = 0 ).
In this case, the samples from the same latent class are embedded to a single point on the hypersphere, and thus arbitrarily small positive angle ⟨ µ ℓ ,µ k ⟩ ∥ µ ℓ ∥·∥ µ k ∥ < 1 is enough to distinguish them by the NN classifier.
In fact, one can quickly verify that ρ max ( σ, δ, ε ) =
∆ µ = 0 holds in the above case.
According to Theorem 1, if µ ⊤ ℓ µ
[Equation]
[Equation]
1 −
[Equation]
[Equation]
[Equation]
then Err( G f ) = 0 , i.e., NN classifier can correctly recognize every sample when µ ⊤ ℓ µ k /r 2 < 1 .
Thus, the condition suggested by Theorem 1 is exactly the same as the intuition.
Theorem 1 implies three key factors to the success of contrastive SSL.
The first one is alignment of positive samples, which is a common objective that contrastive algorithms aim to optimize.
Better alignment enables smaller R ε , which directly decreases the generalization error bound (3).
The second factor is divergence of class centers, i.e., the distance between class centers should be large enough (small µ ⊤ ℓ µ k ).
The divergence condition (2) is related to the alignment ( R ε ) and data augmentation ( σ, δ ).
Better alignment and sharper concentration indicate smaller ρ max ( σ, δ, ε ) , and hence looser divergence condition.
The third factor is concentration of augmented data.
When δ is given, sharper concentration implies larger σ , which directly affects the generalization error bound (3).
For example, richer data augmentations lead to sharper concentration (see the paragraph below Definition 1), and hence better generalization error bound.
Only the first two factors can be optimized during the learning process, and we will provably show how it can be achieved via two concrete examples in Section 4.
In contrast, the third factor is priorly decided by the pre-defined data augmentation and is independent of the learning process.
We will empirically study how the concentration of augmented data affects the downstream performance in Section 5.
In summary, Theorem 1 provides a framework for different algorithms to analyze their generalization abilities.
Compared with the alignment and uniformity proposed by Wang & Isola (2020), both of the works have the same meaning of “alignment” since it is the objective that contrastive algorithms aim to optimize, but our “divergence” is fundamentally different from their “uniformity”.
Uniformity requires “all data” uniformly distributed on the embedding hypersphere, while our divergence characterizes the cosine distance between “class centers”.
We do not require the divergence to be as large as better, instead, the divergence condition can be loosened by better alignment and concentration properties.
As an example, consider the case below Theorem 1.
Since all the samples from the same latent class are embedded into a single point on the hypersphere, in that case, an arbitrarily small positive angle (arbitrarily small divergence) is enough to distinguish them.
More importantly, alignment and uniformity are empirical predictors for downstream performance, while our alignment and divergence have explicit theoretical guarantees (Theorem 1) for the generalization of contrastive
SSL.
Moreover, Wang & Isola (2020) does not consider the crucial effect of data augmentation.
In fact, with bad concentration (e.g., only using identity transformation as data augmentation), “perfect” alignment along with “perfect” uniformity still can not imply good downstream performance.
3. U PPER B OUND R ε VIA A LIGNMENT
We now upper bound R ε via the alignment
[Equation]
which is a common objective of contrastive losses.
Recall that R ε can be rewritten as
[Equation]
We separate the augmentation set A as discrete transformations { A γ ( · ): γ ∈ [ m ] } and continuous transformations { A θ ( · ): θ ∈ [0 , 1] n } .
For example, random cropping or flipping can be categorized into the discrete transformation, while the others like random color distortion or Gaussian blur can be regarded as the continuous transformation parameterized by the augmentation strength θ .
Without loss of generality, we assume that for any given x , its augmented data are uniformly random sampled, i.e., P [ x ′ =
A γ ( x )] = 12 m and P [ x ′ ∈
{ A θ ( x ): θ ∈ Θ } ] = vol(Θ) for any Θ ⊆ [0 , 1] n , where vol(Θ) denotes the volume of Θ .
For the continuous transformation, we further assume that the transformation is M -Lipschitz continuous w.r.t.
θ , i.e., ∥ A θ 1 ( x ) − A
θ 2 ( x ) ∥
≤ M ∥
θ 1 − θ 2 ∥ for any x , θ 1 , θ 2 .
With the above setting, we have the following theorem (proof is deferred to the appendix).
Theorem 2.
If encoder f is L -Lipschitz continuous, then
[Equation]
where η ( ε ) = inf h ∈ (cid:16) 0 ,
[Equation]
The above theorem confirms that, with good alignment, R ε is guaranteed to be small.
C ONTRASTIVE L OSSES M EET A LIGNMENT AND D IVERGENCE
We now study two canonical contrastive losses, the InfoNCE loss and the cross-correlation loss, to see how they can achieve good alignment (small L align ( f ) ) and good divergence (small µ ⊤ k µ ℓ ).
4. I NFO NCE L OSS
The population loss of InfoNCE (Chen et al., 2020a; He et al., 2020) is well known as:
[Equation]
where encoder f is normalized by ∥ f ∥ = 1 .
It can be divided into two parts:
[Equation]
Regardless of the constant factors, L InfoNCE( f ) is exactly the alignment term in (4).
Next, we take a close look at L InfoNCE( f ) to see how it links to the divergence condition required by Theorem 1.
Theorem 3.
Assume that encoder f
with norm 1 is L -Lipschitz continuous.
If the augmented data is ( σ, δ ) -augmented, then for any ε ≥ 0 and k ̸ = ℓ , we have
[Equation]
, where τ ( σ, δ, ε, R ε ) is a non-negative term, decreasing with smaller ε, R ε or sharper concentration of augmented data, and τ ( σ, δ, ε, R ε )
= 0 when σ = 1 , δ = 0 , ε = 0 , R ε = 0 .
The specific formulation of τ ( σ, δ, ε, R ε ) and the proof are deferred to the appendix.
We remark that data augmentation ( σ, δ ) , parameter ε , and p k , p ℓ are pre-determined before training procedure, and thus the upper bound of µ ⊤ k µ ℓ in Theorem 3 varies only with L InfoNCE( f ) and R ε , positively.
Therefore, minimizing L InfoNCE =
L InfoNCE( f ) + L InfoNCE( f ) leads to both small L InfoNCE( f ) and small L InfoNCE( f ) .
Small L InfoNCE( f ) indicates good alignment L align ( f ) , as well as small R ε (Theorem 2).
Small L InfoNCE( f ) along with small R ε indicates good divergence (small µ ⊤ k µ ℓ ) by Theorem 3.
Hence, optimizing the InfoNCE loss can achieve both good alignment and good divergence.
According to Theorem 1 and Theorem 2, the generalization ability of encoder f on the downstream task is implied, i.e., Err( G f ) ≤ (1 − σ ) + η ( ε ) (cid:112) 2 + 2 L InfoNCE( f ) , when the upper bound of µ ⊤ k µ ℓ in Theorem 3 is smaller than the threshold in Theorem 1.
It is worth mentioning that the form of InfoNCE is critical to meeting the requirement of divergence, which is found when we prove Theorem 3.
For example, let us consider the contrastive loss (5) formulated in a linear form 2 instead of LogExp such that
[Equation]
where L ′ 2 ( f ) is the negative-pair term weighted by some λ > 0 .
Due to the independence between x and x ′ , we have L ′ 2 ( f ) =
∥
E x E x 1 ∈ A ( x ) [ f ( x 1 )] ∥ 2 .
Therefore, minimizing L ′ 2 ( f ) only leads to the representation with zero mean.
Unfortunately, the objective of zero mean with ∥ f ∥ = 1 can not obviate the dimensional collapse (Hua et al., 2021) of the model.
For example, the encoder f can map the input data from multi classes into two points in the opposite directions on the hypersphere.
This justifies the observation in (Wang & Liu, 2021): the uniformity of the encoder on the embedded hypersphere becomes worse when the temperature of the loss increases, where the loss degenerates to L ′ ( f ) with infinite temperature.
[Equation] ORRELATION L OSS
Cross-correlation loss is first introduced by Barlow Twins (Zbontar et al., 2021).
In contrast to
InfoNCE loss, it trains the model via decorrelating the components of representation instead of directly optimizing the geometry of embedding space, but it is still observed to have clustered embedding space.
To explore this, we study the cross-correlation loss in detail and show how it implicitly optimizes the alignment and divergence required by Theorem 1.
The population loss of cross-correlation can be formulated as
[Equation]
with normalization condition of E x E x 1 ∈ A ( x ) [ f i ( x 1 )] = 0 and E x E x 1 ∈ A ( x )
[ f i ( x 1 ) 2 ] = 1 for each i ∈ [ d ] , where d is the output dimension of encoder f .
Positive coefficient λ balances the importance between diagonal and non-diagonal elements of cross-correlation matrix.
When λ = 1 , the above loss is exactly the difference between the cross-correlation matrix and identity matrix.
Similar to
Section 4.1, we first divide the loss into two parts, by defining
L Cross
[Equation]
L
[Equation]
In this way, the cross-correlation loss becomes L Cross-Corr =
(1 − λ )
L Cross( f ) + λ L Cross( f ) .
Then, we connect L Cross( f ) and L Cross( f ) with the alignment and divergence, respectively.
Lemma 4.1.
For a given encoder f , the alignment L align ( f ) in (4) is upper bounded via L Cross [Equation] f [Equation]
[Equation]
where d is the output dimension of encoder f .
The above lemma connects L Cross( f ) with L align ( f ) , indicating that the diagonal elements of the cross-correlation matrix determine the alignment of positive samples.
Next, we will link L Cross( f ) to the divergence µ ⊤ k µ ℓ .
It is challenging because L Cross( f ) is designed for reducing the redundancy between the encoder’s output units, not for optimizing the geometry of embedding space.
Theorem 4.
Assume that encoder f with norm √ d is L -Lipschitz continuous.
If the augmented data is ( σ, δ ) -augmented, then for any ε ≥ 0 and k ̸ = ℓ , we have
[Equation]
where τ ′ ( σ, δ, ε, R ε ) is an upper bound of ∥ E x E x 1 , x
2 ∈ A ( x ) [ f ( x 1 ) f ( x 2 ) ⊤ ] − (cid:80)
Kk = 1 p k µ k µ ⊤ k ∥ 2 .
The specific formulation of τ ′ ( σ, δ, ε, R ε ) and proof are deferred to the appendix.
Here we remark that τ ′ ( σ, δ, ε, R ε ) is a non-negative term, decreasing with smaller ε, R ε or sharper concentration of augmented data, and τ ′ ( σ, δ, ε, R ε )
= 0 when σ = 1 , δ = 0 , ε = 0 , R ε = 0 .
Since data augmentation ( σ, δ ) , parameter ε , and p k , p ℓ are pre-determined before training procedure, the upper bound of µ ⊤ k µ ℓ in Theorem 4 varies only with L Cross( f ) and R ε , positively.
Therefore, minimizing L Cross-Corr leads to small L Cross( f ) , as well as small L Cross( f ) .
Small L Cross( f ) indicates good alignment L align ( f ) by Lemma 4.1 and small R ε by Theorem 2.
Small L Cross( f ) along with small R ε indicates good divergence (small µ ⊤ k µ ℓ ) by Theorem 4.
Hence, decorrelating the components of representation can achieve both good alignment and good divergence.
According to
Theorem 1 and Theorem 2, the generalization ability of encoder f on the downstream task is implied, i.e., Err
[Equation]
L Cross( f ) 14 , when the upper bound of µ ⊤ k µ ℓ in Theorem 4 is smaller than the threshold in Theorem 1.
Beyond the above two widely used contrastive learning losses, we further analyze a very recently proposed t -InfoNCE loss (Hu et al., 2022), which is a t -SNE style loss inspired by stochastic neighbor embedding.
We show that it can also achieve good alignment and divergence in the appendix.
E MPIRICAL S TUDY OF C ONCENTRATION OF A UGMENTED DATA
Theorem 1 reveals that sharper concentration of augmented data w.r.t.
the proposed augmented distance implies better generalization error bound regardless of algorithm.
In this section, we empirically study the relationship between the concentration level and the real downstream performance.
Basic Setup.
Our experiments are conducted on CIFAR-10 and CIFAR-100 (Krizhevsky, 2009).
We consider 5 different kinds of transformations for performing data augmentations: (a) random cropping; (b) random Gaussian blur; (c) color dropping (i.e., randomly converting images to grayscale); (d) color distortion; (e) random horizontal flipping.
We test different combinations of transformations via various SSL algorithms such as SimCLR (Chen et al., 2020a), Barlow Twins (Zbontar et al., 2021),
MoCo (He et al., 2020), and SimSiam (Chen & He, 2021).
We use ResNet-18 (He et al., 2016) as the encoder, and the other settings such as projection head remain the same as the original settings of algorithms.
Each model is trained with a batch size of 512 and 800 epochs.
To evaluate the quality of the encoder, we follow the KNN evaluation protocol (Wu et al., 2018).
Different Richness of Augmentations.
We compose all 5 kinds of transformations together, and then successively drop one of the composed transformations from (e) to (b) to conduct 5 experiments for each dataset (Table 1).
We observe that the downstream performance monotonously gets worse with the decrease of transformation number, under all four SSL algorithms, on both CIFAR-10 and
CIFAR-100.
Notice that richer augmentation implies sharper concentration (see the paragraph below
Definition 1), and thus the concentration becomes less sharp from top to bottom for each dataset.
Therefore, we observe that downstream performance becomes better with sharper concentration.
We also observe that (c) color dropping and (d) color distortion have a great impact on the performance of all algorithms.
According to our theoretical framework, these two transformations enable the augmented data to vary in a very wide range, which makes the augmented distance (1) largely decrease.
As an intuitive example, if the right dog image in Figure 2 is replaced by a Husky image, only with random cropping, one will get two dog heads with similar shapes but different colors, which still have a large augmented distance.
Instead, if color distortion is further applied, one can get two similar dog heads both in shape and color.
Therefore, these two dog images have similar augmented views, and thus their augmented distance (1) becomes very small.
Notice that small augmented distance (1) indicates sharp concentration (small δ in Definition 1).
Therefore, we observe that dramatic change in concentration leads to wildly fluctuating downstream performance. [Table] [Table]
Different Strength of Augmentations.
We fix (a) random cropping and (d) color distortion as data augmentation, and vary the strength of (d) in { 1 , 12 , 14 , 18 } to construct 4 groups of augmentations with different strength levels (Table 2).
We observe that the downstream performance monotonously decreases with weaker color distortions, under all four SSL algorithms, on both CIFAR-10 and
CIFAR-100.
Recall that a stronger color distortion makes the augmented data vary in a wider range, leading to a smaller augmented distance (1) and thus sharper concentration.
Therefore, we observe again that downstream performance becomes better with sharper concentration.
Different Composed Pairs of Transformations.
To study the relationship between the concentration level and the corresponding downstream performance in a more fine-grained way, we compose transformations (a)-(e) in pairs to construct a total of (cid:0) 52 (cid:1) = 10 augmentations.
Contrasted to the previous two groups of experiments, current composed augmentations do not have an apparent order of concentration levels.
According to Definition 1, for a given δ , a smaller (1 − σ ) corresponds to a sharper concentration.
Thus, we mathematically compute (1 − σ ) (see appendix for details), and observe the correlation between classification error rate Err( G f ) and (1 − σ ) under different δ on
CIFAR-10, based on the SimCLR model trained with 200 epochs.
Interestingly, downstream performance is surprisingly highly correlated to the concentration level (Figure 3).
Specifically, if we fix one of composed transformations as (a), we find that both Err( G f ) and (1 − σ ) have the same order
that ( a, d ) <
( a, c ) < ( a, e ) ≈ ( a, b ) , under two values of δ .
Furthermore, among all 10 composed augmentations, augmentation ( a, d ) has the smallest value of (1 − σ ) , while the corresponding performance is also the best one.
In addition, we observe that the choice of δ is not sensitive to the curve shape of (1 − σ ) .
These observations suggest that sharper concentration is most likely to have better downstream performance.
This also provides an explanation for Figure 5 in SimCLR paper (Chen et al., 2020a) of why the composition of “crop & color” performs the best.
A CKNOWLEDGMENT
We would like to express our sincere gratitude to the reviewers of ICLR 2023 for their insightful and constructive feedback. Their valuable comments have greatly contributed to improving the quality of our work.
A C OMPUTE σ FOR F IGURE
When δ is given, for each class C k , we construct an auxiliary graph G k whose nodes correspond to the samples of C k and edge ( x 1 , x 2 ) exists if d A ( x 1 , x 2 ) ≤ δ .
According to Definition 1, we can compute the main part of C k by finding the maximum clique of graph G k .
Then σ can be estimated by min k ∈
[ K ] | M AX C LIQUE ( G k ) | / | C k | .
We solve M AX C LIQUE via its dual problem – vertex cover, and adopt the Approx-Vertex-Cover (Papadimitriou & Steiglitz, 1998) to compute the solution.
B P ROOFS FOR S ECTION
Lemma 3.1.
For a ( σ, δ ) -augmentation with main part C 0 k of each class C k , if all samples belonging to ( C 01 ∪ · · · ∪ C 0 K ) ∩ S ε can be correctly classified by a classifier G , then its classification error rate Err( G ) is upper bounded by (1 − σ ) + R ε .
Proof.
Since every sample x ∈ ( C 0 1 ∪ · · · ∪ C 0 K ) ∩ S ε can be correctly classified by G , then the classification error rate
[Equation]
This finishes the proof.
Lemma 3.2.
Given a ( σ, δ ) -augmentation used in contrastive SSL, for any ℓ ∈ [ K ] , if µ ⊤ ℓ µ k < r 2 (cid:16) 1 − ρ ℓ ( σ, δ, ε ) − (cid:112) 2 ρ ℓ ( σ, δ, ε ) − ∆ µ 2 (cid:17) holds for all k ̸ = ℓ , then every sample x ∈ C 0 ℓ ∩ S ε can be correctly classified by the NN classifier G f , where ρ ℓ ( σ, δ, ε ) =
2(1 − σ ) + R ε p ℓ + σ (cid:0) Lδr + 2 εr (cid:1) and ∆ µ = 1 − min k ∈
[ K ] ∥ µ k ∥ 2 /r 2 .
Proof.
Without loss of generality, we consider ℓ = 1 .
To show that every sample x 0 ∈ C 01 ∩ S ε can be correctly classified by G f , we need to prove that for all k ̸ = 1 , ∥ f
( x 0 ) − µ 1 ∥ <
∥ f ( x 0 ) − µ k ∥ .
It is equivalent to prove that
[Equation]
Let ˜ f
( x ) :=
E x ′ ∈
A ( x ) [ f ( x ′ )] .
Then ∥
˜ f
( x ) ∥ =
∥
E x ′ ∈
A ( x ) [ f ( x ′ )]
∥ ≤ E x ′ ∈
A ( x ) [ ∥ f ( x ′ ) ∥ ]
= r .
On the one hand,
[Equation]
where I ( · ) is the indicator function.
Note that
[Equation]
and
[Equation]
Plugging to (7), we have
[Equation]
Notice that x 0 ∈ C 01 ∩ S ε .
For any x ∈ C 01 ∩ S ε , we have d A ( x 0 , x ) ≤ δ .
Let ( x ∗ 0 , x ∗ ) =
arg min x ′
∈ A ( x 0 ) , x ′ ∈
A ( x ) ∥ x ′
− x ′ ∥ .
We have ∥ x ∗ 0 − x ∗ ∥ ≤ δ .
Since f is L -Lipschitz continuous, we have ∥ f ( x ∗ 0 ) − f ( x ∗ )
∥ ≤ L ·∥ x ∗ 0 − x ∗ ∥ ≤ Lδ .
Since x ∈ S ε , for any x ′ ∈ A ( x ) , ∥ f ( x ′ ) − f ( x ∗ ) ∥
≤ ε .
Similarly, since x 0 ∈ S ε and x 0 , x ∗ 0 ∈
A ( x 0 ) , we have ∥ f ( x 0 ) − f ( x ∗ 0 )
∥ ≤ ε .
The first term of (10) can be bounded by
[Equation]
= r 2 − r ( Lδ + 2 ε ) .
Therefore
[Equation]
(10) turns to
[Equation]
On the other hand,
[Equation]
Note that ∆ µ = 1 − min k ∥ µ k ∥ 2 /r 2 , the LHS of (6) is
[Equation]
where the second iequality is due to (11) and (12).
This finishes the proof.
Theorem 1.
Given a ( σ, δ ) -augmentation used in contrastive SSL, if
[Equation]
holds for any pair of ( ℓ, k ) with ℓ ̸
= k , then the downstream error rate of NN classifier G f
[Equation]
where ρ max ( σ, δ, ε )
=
2(1 − σ )
+
[Equation]
Proof.
Since the augmentation A is ( σ, δ ) -augmented, there exists a main part C 0 k for each class C k such that P [ C 0 k ] ≥ σp k and sup x 1 , x 2 ∈ C
k d A ( x 1 , x 2 ) ≤ δ .
Since for any ℓ ̸ = k , we have µ ⊤ ℓ
[Equation]
According to Lemma 3.2, every sample x ∈ C 0 ℓ ∩ S ε can be correctly classified by G f .
Therefore, every sample x ∈ ( C 01 ∩ · · · ∩ C 0 K ) ∩ S ε can be correctly classified by G f .
According to Lemma 3.1, the error rate Err( G f ) ≤ 1 − σ + R ε .
Theorem 2.
If encoder f is L -Lipschitz continuous, then
[Equation]
where η ( ε ) = inf h ∈ (cid:16) 0 ,
[Equation]
Proof.
The parameter space [0 , 1] n of θ can be separated to cubes Θ 1 , . . .
, Θ m ′ where m ′ = 1 /h n
and each cube’s edge length is h ∈ (0 , ε 2 √ nLM ) .
Then for any given x , we have
[Equation]
∥
[Equation]
x
[Equation]
x
[Equation]
(cid:124) (cid:123)(cid:122) (cid:125) Λ
[Equation]
+ 4 m ′
[Equation]
m ′ (cid:88) i = m ′ (cid:88)
j = (cid:90) Θ i (cid:90) Θ
j
[Equation]
x
[Equation]
x
[Equation]
(cid:124) (cid:123)(cid:122) (cid:125)
Λ.
By Cauchy-Schwarz inequality,
[Equation]
Then for any given θ ,
[Equation]
Therefore
[Equation]
for any γ ∈ [ m ]
[Equation]
j ∈ [ m ′ ]
[Equation]
we have
[Equation]
Similarly [Equation] we can obtain sup
[Equation]
Therefore, sup
[Equation]
= max   
[Equation]
] ,j ∈ [ m ′ ] sup θ ′ ∈
Θ j ∥ f
( A γ ( x )) − f ( A θ ′ ( x ))
∥ sup i,j ∈ [ m ′ ]
sup θ ∈ Θ
i ,θ ′ ∈
Θ j ∥ f
( A θ ( x )) − f ( A θ ′ ( x ))
∥
   ≤ max   sup γ,β ∈ [ m ] ∥ f
( A γ ( x )) − f ( A β ( x ))
∥ sup γ ∈ [ m ] ,j ∈ [ m ′ ] (cid:82) Θ j 1 h n ∥ f
( A γ ( x )) − f ( A θ ( x ))
∥ dθ + √ nLMh sup i,j ∈ [ m ′ ] (cid:82) Θ
i (cid:82) Θ j 1 h 2 n ∥ f
( A θ 1 ( x )) − f
( A θ 2 ( x )) ∥ dθ 2 dθ 1 +2 √ nLMh  
[Equation]
Thus
[Equation]
the following set S is a subset of S ε :
[Equation]
Then by Markov’s inequality
[Equation]
we have
[Equation]
The above inequality holds for all h ∈ (0 , ε 2 √ nLM ) , thus
R ε ≤ inf
[Equation]
Therefore, we have
[Equation]
This finishes the proof.
C P ROOFS FOR S ECTION
Before providing our proofs, we give the following useful lemma, which upper bounds the first and second order moment of intra-difference within each class C k via ε and R ε .
Lemma C.1.
Suppose that ∥ f ( x ) ∥ =
r for every x .
For each k ∈ [ K ] ,
[Equation]
and
E x ∈ C k
E
[Equation]
Proof.
For each k ∈ [ K ] ,
[Equation]
where
[Equation]
For any x
[Equation]
x ′ ∈ C 0 1 ∩ S ε , we have d A ( x , x ′ ) ≤ δ .
Let ( x ∗ 1 , x ∗ 2 ) =
arg min x 1 ∈
A ( x ) , x 2 ∈ A ( x ′ )
∥ x 1 − x 2 ∥ .
We have ∥ x ∗ 1 − x ∗ 2 ∥ ≤ δ .
Since f is L -Lipschitz continuous, we have ∥ f ( x ∗ 1 ) − f ( x ∗ 2 )
∥ ≤
L · ∥ x ∗ 1 − x ∗ 2 ∥ ≤ Lδ .
Since x ∈ S ε , for any x 1 ∈ A ( x ) , ∥ f ( x 1 ) − f ( x ∗ 1 ) ∥ ≤ ε .
Similarly, since x ′ ∈ S ε , for any x 2 ∈ A ( x ′ ) , we have ∥ f ( x 2 ) − f ( x ∗ 2 )
∥ ≤ ε .
Therefore, for any x , x ′ ∈ C 01 ∩ S ε and x 1 ∈ A ( x ) , x 2 ∈ A ( x ′ ) ,
[Equation]
Plugging into (13) and (14), we obtain
[Equation]
Similar to (13) and (14), we have
[Equation]
and
[Equation]
Therefore,
[Equation]
This finishes the proof.
Now we are ready to give our proofs of theorems.
C. I NFO NCE L OSS
Theorem 3.
Assume that encoder f
with norm 1 is L -Lipschitz continuous.
If the augmented data is ( σ, δ ) -augmented, then for any ε ≥ 0 and k ̸ = ℓ , we have
[Equation]
where τ ( σ, δ, ε, R ε ) is a non-negative term, decreasing with smaller ε, R ε or sharper concentration of augmented data, and τ ( σ, δ, ε, R ε )
= 0 when σ = 1 , δ = 0 , ε = 0 , R ε = 0 .
Proof.
Given x ∈ S ε , for any x [Equation] x 2 ∈ A ( x )
[Equation]
we have
[Equation]
Therefore
[Equation]
we have
[Equation] [Equation]
where ∆ 1 is defined as
[Equation]
+
[Equation]
Then, | ∆ 1 |
[Equation]
≤ (1 + log 2) R ε
+
K (cid:88)
[Equation]
(mean value theorem,
[Equation]
[ − 1 , 1] ) ≤ (1 + log 2) R ε +
K
[Equation]
≤ (1 + log 2) R ε
+
[Equation]
[Equation] [Equation]
+ ∥ f ( x 1 ) − µ k ∥ ·
∥ µ ℓ ∥ + ∥ µ k ∥ · ∥ f ( x − ) − µ ℓ ∥ (cid:3)
[Equation] [Equation]
Then (15) turns to
[Equation]
≤ L InfoNCE
[Equation]
Let τ
[Equation]
[Equation]
[Equation]
[Equation]
ε , and we obtain
[Equation]
This finishes the proof.
C. C ROSS -C ORRELATION L OSS
Lemma 4.1.
For a given encoder f , the alignment L align ( f ) in (4) is upper bounded via L Cross( f ) :
[Equation]
where d is the output dimension of encoder f .
Proof.
Since E x E x 1 ∈ A ( x ) f i ( x 1 ) 2 = [Equation] for each coordinate component i [Equation]
we have
[Equation]
Then
E
[Equation]
where the inequality holds due to the Cauchy inequality.
Lemma C.2.
Assume that encoder f with norm √ d is L -Lipschitz continuous.
If the augmented data is ( σ, δ ) -augmented, then for any ε ≥ 0 ,
[Equation]
where τ ′ ( σ, δ, ε, R ε ) is defined as
[Equation]
Proof.
We first decompose the LHS as
[Equation]
Then its norm is
[Equation]
[Equation]
This finishes the proof.
Theorem 4.
Assume that encoder f with norm √ d is L -Lipschitz continuous.
If the augmented data is ( σ, δ ) -augmented, then for any ε ≥ 0 and k ̸ = ℓ , we have
[Equation]
where τ ′ ( σ, δ, ε, R ε ) is an upper bound of ∥ E x E x 1 , x
2 ∈ A ( x ) [ f ( x 1 ) f ( x 2 ) ⊤ ] − (cid:80)
Kk =
1 p k µ k µ ⊤ k ∥ 2 .
Proof.
Let U =
( √ p 1 µ 1 , . . . , √ p K µ K
) ∈ R d × K .
[Equation]
where δ kl is the Dirichlet function
[Equation]
Therefore,
[Equation]
=1 p
[Equation]
This finishes the proof
[Equation]
D A NALYSIS OF t -I NFO NCE
The population loss of t -InfoNCE
(Hu et al., 2022) can be written as:
[Equation]
It can be divided into two parts:
[Equation]
Similar to the InfoNCE loss and the cross-correlation loss, we can connect L 1 ( f ) and L 2 ( f ) with the alignment and divergence by the following Lemma D.1 and Theorem 5, respectively.
Lemma D.1.
For a given encoder f , the alignment L align ( f ) in (4) is upper bounded via L 1 ( f ) , i.e.,
[Equation]
Proof.
It is easy to verify that log(1 + t 2 ) ≥ ln54 t 2 for any t ∈ [0 , 2] .
Since ∥ f ( x 1 ) − f ( x 2 ) ∥ ∈ [0 , 2] , we have
[Equation]
Thus,
L
[Equation]
This finishes the proof.
Theorem 5.
Assume that encoder f
with norm 1 is L -Lipschitz continuous.
If the augmented data is ( σ, δ ) -augmented, then for any ε > 0 and k ̸ = ℓ ,
[Equation]
where τ ′′ ( σ, δ, ε, R ε ) is a non-negative term, decreasing with smaller ε, R ε or sharper concentration of augmented data, and τ ( σ, δ, ε, R ε )
= 0 when σ = 1 , δ = 0 , ε = 0 , R ε =
Proof.
Given x ∈ S ε , for any x 1 , x 2 ∈
A ( x ) , we have
[Equation]
3 −
[Equation]
f ( x 1 ) ⊤ f
[Equation]
x 1 ) −
[Equation]
f ( x 1 )
[Equation]
( f ( x
[Equation] [Equation]
f ( x 1 )
[Equation]
3 −
[Equation]
f ( x 1 )
[Equation]
f ( x − ) (cid:21) ≥ log (cid:20)
[Equation]
2 ∥ f
( x 1 ) ∥ 2 + 2 ∥ f ( x 1 ) ∥ · ε
[Equation]
3 − 2 f ( x 1 )
⊤ f ( x − ) (cid:21) = log (cid:20)
[Equation]
2 ε
[Equation]
[Equation]
f ( x 1 ) ⊤ f ( x − ) (cid:21) .
Therefore
[Equation]
we have
[Equation] [Equation]
where ∆ 1 is defined as
[Equation]
=
[Equation] E [Equation] x
[Equation] ( x ′ ) (cid:20) log (cid:18) 1 + 2 ε + 3 − 2 f ( x 1 )
⊤ f ( x − ) (cid:19) − log (cid:32) 1 + 2 ε + 3 − 2 µ ⊤ k µ ℓ (cid:33) (cid:21) .
Then, | ∆ 1 | ≤
K (cid:88)
[Equation]
+
[Equation]
E
[Equation]
x
[Equation]
(cid:20)
[Equation]
{+(cid:18) 
+}
+ 2 ε + 3 − 2 f ( x 1 )
⊤ f ( x − ) (cid:19) − log (cid:32) 1 + 2 ε + 3 − 2 µ ⊤ k µ ℓ (cid:33) (cid:21) ≤
[Equation]
E
[Equation]
x −
[Equation] [Equation]
[Equation]
f
[Equation]
ℓ |
[Equation]
(mean value theorem, ξ ∈ [ − 1 , 1] ) ≤ R
ε log 2 +
K (cid:88) k
=
K (cid:88) ℓ =
E x , x ′
[Equation]
ℓ )
E x 1 ∈ A
[Equation]
x )
[Equation]
 ≤
[Equation]
(using (16))
Therefore, according to (17), p
[Equation]
Let τ
[Equation]
and we obtain
[Equation]
This finishes the proof.
E A DDITIONAL P ROOFS
We give detailed proof of the linear reformulation of the nearest neighbor classifier in this section.
Proposition E.1 (Linear reformulation of the NN classifier) .
Let G f ( x ) =
arg min k ∈ [ K ] ∥ f ( x ) − µ k ∥ be the NN classifier.
Then
[Equation]
which is also a linear classifier.
Proof.
G f ( x ) =
k means for each l ∈
[ K ] ,
[Equation]
This is equivalent to
[Equation]
holds for each ℓ ∈ [ K ] .
Therefore, G f ( x ) = arg max k ∈
[ K ] (cid:0) µ ⊤ k f ( x ) − 12 ∥ µ k ∥ 2 (cid:1) , which is a linear classifier.
F A N EXTENSION TO A ( C k ) ∩ A ( C ℓ ) ̸ = ∅
In this section, we extend our theory to the case where A ( C k ) ∩ A ( C ℓ ) ̸ = ∅ for some k ̸ = ℓ , i.e., augmentation could introduces wrong signals.
To quantify this negative effect, we introduce the following definition.
Definition 2 (Correctly augmented parts) .
We define the corrected augmented parts of augmentation
A by
[Equation]
for each k ∈ [ K ] .
We also denote the probability of their complement as t := 1 − P ( ∪ Kk =1 ˜ C k ) .
By the definition, clearly
A ( ˜ C ℓ ) ∩ A ( ˜ C k )
= ∅ , hence our theory in the main body applies to ∪ Kk =1 ˜ C k .
To see this, we first generalize the definition of ( σ, δ ) -augmentation to the correctly augmented parts in the following.
Definition 3 ( ( σ, δ ) -Augmentation on corrected augmented parts) .
The augmentation set A is called a ( σ, δ ) -augmentation on correctly augmented parts, if for each ˜ C k , there exists a subset C 0 k ⊆ ˜
C k (called a main part of ˜ C k ),
such that both P [ x ∈ C 0 k ] ≥ σ P [ x ∈ ˜ C k ] where σ ∈ (0 , 1] and sup x 1 , x 2 ∈ C
k d A ( x 1 , x 2 ) ≤ δ hold.
Besides, we modify the definition of µ k by µ k := E x ∈ ˜ C
k E x ′
∈
A ( x ) [ f ( x ′ )] .
Then we have a generalized version of Theorem 1.
Theorem 6 (A generalized version of Theorem 1) .
Given an augmentation A that is a ( σ, δ ) - augmentation on corrected augmented parts, if
[Equation]
[Equation]
holds for any pair of ( ℓ, k ) with ℓ ̸
= k , then the downstream error rate of NN classifier G f
[Equation]
(19) where ρ max ( σ, δ, ε )
=
2(1 − σ )
+
R ε min ℓ p ℓ + σ (cid:0) Lδr +
[Equation]
and ∆ µ = 1 − min k ∈ [ K ] ∥ µ k ∥ 2 /r 2 .
We remark that the definition of R ε is unchanged.
The above result gives a more general bound
[Equation]
by taking into account the correctly augmented part.
An interesting trade-off between t and ( σ, δ ) emerges.
Increasing the strength of data augmentation leads to better concentration, but also a larger t .
For extremely strong augmentations, t could be large and dominate the above bound, hence the performance could decrease.
We leave the detailed study of this trade-off to future work.
Proof of Theorem 6.
Let ˜ R ε :=
P (cid:104) S ε ∩ ( ∪ k ∈
[ K ] ˜ C k ) (cid:105) .
Then using Theorem 1 on ∪ Kk =1 ˜
C k directly gives
[Equation]
Moreover,
[Equation]
which completes the proof.
G E XTENSIONS TO MAE, CLIP AND BYOL
In this section, we discuss how to apply our framework to MAE (He et al., 2022), CLIP (Radford et al., 2021) and BYOL (Grill et al., 2020).
G. MAE
MAE learns representations by recovering the original image from its randomly masked version.
By viewing random mask as data augmentation, Zhang et al. (2022) has shown that MAE implicitly aligns positive pairs as contrastive learning.
Specifically, let g and f be the decoder and encoder of
MAE respectively.
The loss function of MAE is
[Equation]
where A ( x ) denotes random masks of x .
Then using Theorem 3.4 in (Zhang et al., 2022) under their conditions gives
[Equation]
where C 1 and C 2 are constants.
Based on this result, our framework applies to MAE naturally.
We can use the ( σ, δ ) -notion to characterize the concentration property of random mask, and use Theorem 1 to study how MAE ensures alignment.
As for the divergence term, we have the following result.
Theorem 7.
Assume that the decoder g is L -bi-Lipschitz, i.e., ∀ ( z 1 , z 2 ) in the domain of g , 1 /L ∥
z 1 − z 2 ∥ 2 ≤ ∥
g
( z 1 ) − g ( z 2 ) ∥ 2 ≤ L ∥
z 1 − z 2 ∥ 2 .
Then for any ℓ, k ∈ [ K ]
[Equation]
where C is some constant.
If we further assume ∥ f ( x ) ∥ = 1 for every x , we have
[Equation]
The L -bi-Lipschitz assumption follows (Zhang et al., 2022).
This result shows that, the divergence bound of MAE contains both the MAE loss and an addition term E x 1 ∈ C ℓ E x
2 ∈ C k ∥ x 1 − x 2 ∥ 2 , which measures the class distances between original images.
If the original images already have large class distances, the divergence can be ensured.
More refined results of MAE may need more additional effort.
Proof of Theorem 7.
For any ℓ, k ∈ [ K ] , by the L -bi-Lipschitz property of g we have
[Equation]
If ∥ f ( x ) ∥ = 1 for any x
[Equation]
we have
[Equation]
Then we obtain
[Equation]
G. CLIP
CLIP firstly constructs positive samples by image-text pairs, and then minimizes InfoNCE loss.
If we view texts as data augmentation of images, our theory applies directly.
To be specific, let T ( x ) denote the set of all possible texts corresponding to image x .
In this case, the augmented distance between images (parallel to equation (1) in our paper) can be defined by
[Equation]
where ∥ · ∥ is some norm of the text space.
Then the ( σ, δ ) notion can also be extended as follows
Definition 4 ( ( σ, δ ) -Concentration of image-text pair) .
We say the image-text pair is ( σ, δ ) - concentrated, if there exists C 0 k ⊆ C k such that
[Equation]
Note that we treat texts and images asymmetrically, i.e., we view texts as augmentation of images.
The reason is that the information density in texts is larger than that in images, namely, images contain more redundant information.
Therefore, for two images in the same class, their corresponding texts are expected to be close to each other, but not vice versa.
Based on this model, all of our theoretical results about InfoNCE loss apply to CLIP.
G. BYOL
BYOL (and SimSiam) adopts training strategies to avoid feature collapse instead of involving an explicit L 2 term in its loss function.
Besides, its network architecture contains a predictor, so its loss can not be formulated to the common alignment loss.
For these reasons, whether BYOL can optimize alignment and divergence cannot be answered directly by our theory.
Nevertheless, our ( σ, δ ) -notion
and Thm 1 still apply to BYOL, since they are algorithm independent.
Besides, our experiments for
SimSiam (which is similar to BYOL) indeed verify this:
• Tables 1 and 2 show that the performance of SimSiam also gets better as the concentration of augmentation gets better, which meets our Theorem 1 and related conclusions.
• The new experimental results in Figure 4b show that SimSiam does implicitly optimize divergence during its optimization procedure.
Further theoretical study of BYOL and SimSiam requires additional effort.
[Figure]
H ADDITIONAL EXPERIMENTS
Alignment and Divergence.
We choose the models with three different loss functions (i.e., Barlow
Twins, SiamSiam and MoCo) and observe how alignment and divergence change during the training procedure.
Each model is trained on CIFAR-10 with a batch size of 512 and 800 epochs.
The setting of data augmentation is fixed as the one that Chen et al.
(2020a) used.
In the experiments, the alignment is quantified by 1 | X | (cid:80) x
∈ X ∥
f ( A 1 ( x )) − f
( A 2 ( x )) ∥ 2 and the divergence is quantified by the average of (cid:16) 1 | C k | (cid:80) x
∈ C k f ( x ) (cid:17) ⊤ (cid:16) 1 | C ℓ | (cid:80) x ∈ C ℓ f ( x ) (cid:17) among all k ̸ = ℓ , where f is the encoder,
A 1 ( x ) and A 2 ( x ) are two augmented data of x , X is the training set, C k contains all the training data with label k .
At the end of the training procedure, Barlow Twins, SimSiam, and MoCo achieve a
KNN accuracy of 86.94, 89.28, and 90.33, respectively.
We have the following observations:
• At the end of the training, both the alignment and divergence are ordered as MoCo <
SimSiam < Barlow Twins, from small to large (i.e., good to bad).
We also observe that MoCo, Simsiam, and Barlow Twins achieve a KNN accuracy of 90.33, 89.28, and 86.94, respectively.
This suggests that better alignment and divergence result in better performance when the setting of data augmentation is fixed.
This empirical result is as expected: as long as good alignment and divergence are achieved, no matter whether it is due to the loss functions (e.g., SimCLR and Barlow Twins, proved in Section 4) or other unknown reasons (e.g., SimSiam), the generalization error should be small according to our Thm 1.
• During the training procedure, the divergence factor always gets better (i.e., smaller) for all three kinds of algorithms.
It decreases more quickly at the early stage of training.
Meanwhile, the alignment factor starts to get better monotonously after several training epochs for MoCo and Barlow Twins.
But for SimSiam, it becomes increasingly large.
This is because SimSiam does not directly minimize the alignment, instead, a predictor is involved to transform the feature of one view and matches it to the other view.
Different Composed Pairs of Transformations on CIFAR-100.
Similar to the experiments on
CIFAR-10, we compose transformations (a)-(e) in pairs to construct a total of 10 augmentations, and observe the correlation between classification error rate Err( G f ) and (1 − σ ) under different δ on CIFAR-100, based on the SimCLR model trained with 200 epochs.
We find that downstream performance is also highly correlated to the concentration level on CIFAR-100, which has the similar result to Figure 3.