T OWARDS THE G ENERALIZATION OF C ONTRASTIVE S ELF -S UPERVISED L EARNING
Anonymous authors
Paper under double-blind review
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.
With the above theoretical findings, we then study two canonical contrastive losses, InfoNCE and cross-correlation, to see how they satisfy the first two factors.
Furthermore, we conduct various experiments to study the third factor, and observe that the downstream performance is highly correlated to 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 both 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 artificially defined self-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, different kinds of 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 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
[Figure]
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 also provide insights for understanding 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 the alignment of positive samples, which is a common objective that contrastive algorithms aim to optimize.
The second one is the divergence of class centers, which prevents the collapse of representation.
The third factor is the 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 which can be optimized by contrastive algorithms, while the third factor is decided by the pre-determined data augmentation.
Thus, data augmentation plays a role as important as algorithms in contrastive SSL.
We then study the above three factors in more depth.
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 in Section 4.
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 the data augmentation; 2) proposing a theoretical framework for contrastive SSL, which suggests that alignment, divergence, and concentration are key factors of generalization ability; 3) provably verifying that not only the InfoNCE loss but also the cross-correlation loss satisfy the alignment and divergence; 4) empirically showing that the concentration w.r.t.
the proposed augmented distance is highly related to the downstream performance.
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).
However, a rigorous relationship between mutual information and the downstream classification error has not been established.
Tschannen et al.
(2019) also find that optimizing tighter bounds of MI does not imply better representations.
Thus, MI may not fully explain the success of InfoNCE.
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 contrastive algorithms.
Ash et al.
(2021) study the role of negative samples in contrastive SSL, and show an interesting collision-coverage trade-off theoretically.
Furthermore, 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), and the “expansion” assumption (Wei et al., 2020).
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 classes never transfer to the same augmented sample, i.e., A ( C k ) ∩ A ( C ℓ ) = ∅ for any k ̸ = ℓ .
Notation ∥ · ∥ stands for ℓ 2 -norm or Frobenius norm for vectors and matrices.
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, a class of methods (Chen et al., 2020a; He et al., 2020) use the InfoNCE loss to push away negative pairs, formulated as
[Equation]
where x , x ′ are two random data points.
Some other methods (e.g., Barlow Twins (Zbontar et al., 2021)) use the cross-correlation loss to decorrelate the components of representation, formulated as
[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 .
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 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 these two distances, we need to take a close look at 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, although they are quite different at the pixel level, they contain similar semantic meanings.
Meanwhile, they have a small augmented distance.
Thus, the semantic distance can be partially characterized by the proposed augmented 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.
One can verify that for any A ′ ⊇
A with richer augmentations, we have 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 3, 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 (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.
For simplicity, 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 µ ⊤ ℓ µ k /r
[Equation]
max ( σ, δ,
[Equation]
− (cid:112)
[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 the 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 (19).
The second factor is the divergence of class centers, i.e., the distance between class centers should be large enough (small µ ⊤ ℓ µ k ).
The divergence condition (18) 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 the concentration of augmented data.
When δ is given, sharper concentration implies larger σ , which directly affects the generalization error bound (19).
For example, richer data augmentations lead to sharper concentration (see the paragraph below Definition 3), and hence better generalization error bound.
Only the first two factors can be optimized by contrastive algorithms, and we will provably show how it can be done via two concrete examples in Section 4.
In contrast, the third factor is priorly decided by the pre-defined data augmentation and is unrelated to algorithms.
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 to 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., 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]
and there is a gap between “ sup operator” in R ε and “ E operator” in L align ( f ) , which cannot be simply derived by concentration inequalities.
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 the good alignment (small L align ( f ) ) and good divergence (small µ ⊤ k µ ℓ ).
4. W ARMUP : 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 Info 1 ( f ) is exactly the alignment term in (4).
Next, we take a close look at L Info 2 ( 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 µ ⊤ k µ ℓ ≤ log (cid:18) exp (cid:26) L Info
[Equation]
( f ) + τ ( σ, δ, ε, R ε ) p k p ℓ (cid:27) − exp(1 − ε ) (cid:19) , 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 Info 2 ( f ) and R ε , positively.
Therefore, minimizing L InfoNCE =
L Info 1 ( f )+ L Info 2 ( f ) leads to both small L Info 1 ( f ) and small L Info 2 ( f ) .
Small L Info 1 ( f ) indicates good alignment L align ( f ) , as well as small R ε (Theorem 2).
Small L Info 2 ( 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 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 Info 1 ( 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 1 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.
4. C ROSS -C 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
[Equation]
and L
[Equation] [Equation]
In this way, the cross-correlation loss becomes L Cross-Corr =
(1 − λ )
L Cross( f ) + λ L Cross( f ) .
Then, we connect L 1 ( f ) and L 2 ( 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 1 ( f ) , i.e.,
[Equation]
where d is the output dimension of encoder f .
The above lemma connects L 1 ( f ) with L align ( f ) , indicating that the diagonal elements of the crosscorrelation matrix determine the alignment of positive samples.
Next, we will link L 2 ( f ) to the divergence µ ⊤ k µ ℓ .
It is challenging because L 2 ( 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
[Equation]
[Equation]
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.,
[Equation]
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 3), 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 3).
Therefore, we observe that dramatic change in concentration leads to wildly fluctuating downstream performance.
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.
[Table] [Table]
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 3, 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.
F UTURE W ORK
One future work can be relaxing the assumption that ∩ Kk =1 A ( C k ) = ∅ , corresponding to the situation that the data augmentation is too aggressive.
Another possible direction is to refine the solution by taking the sample size into account, to justify the phenomenon that batch size is sensitive to the performance of SimCLR but not sensitive to Barlow Twins.
Appendix 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 3, 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 f ( x 0 )
⊤
[Equation]
= r 2 − r ( Lδ + 2 ε ) .
Therefore
[Equation]
(10) turns to
[Equation]
On the other hand,
[Equation] [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]
By Cauchy-Schwarz inequality,
[Equation]
Then for any given θ ,
[Equation]
Therefore
[Equation]
for any γ ∈ [ m ]
[Equation]
j ∈ [ m ′ ]
[Equation]
we have
[Equation]
Similarly, we can obtain
[Equation]
Therefore, sup
[Equation]
= max
[Equation]
 
[Equation]
m ] ,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
[Equation]
Therefore
[Equation]
we have
[Equation]
This finishes the proof.
C P ROOFS FOR S ECTION
Before providing our proofs
[Equation]
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 x
[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)
[Equation]
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 1 , x 2 ∈ A ( x )
[Equation]
we have
[Equation]
Therefore
[Equation]
we have
[Equation] [Equation]
where ∆ 1 is defined as
[Equation]
Then, | ∆ 1 |
[Equation]
≤ (1 + log 2) R
[Equation]
+
K
[Equation]
(mean value theorem,
[Equation]
∈ [ − 1 , 1] ) ≤ (1 + log 2) R ε +
K (cid:88)
[Equation]
16) ≤ (1 + log 2) R ε +
K (cid:88)
[Equation]
x
[Equation]
) − µ
[Equation] [Equation]
+ ∥ f ( x 1 ) − µ k ∥ ·
∥ µ ℓ ∥ + ∥ µ k ∥ · ∥ f ( x − ) − µ ℓ ∥ (cid:3)
[Equation] [Equation]
Then (15) turns to
[Equation]
Let τ
[Equation]
σ, δ,
[Equation]
, R
[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 1 ( f ) ,
i
[Equation]
e.,
[Equation]
where d is the output dimension of encoder f .
Proof.
Since E x E x 1 ∈ A ( x ) f i ( x 1 ) 2 = 1 , for each coordinate component i , we have
[Equation]
Then
[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]
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]
K
[Equation]
where δ kl is the Dirichlet function
[Equation]
Therefore,
[Equation]
This finishes the proof.
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]
(cid:20)
[Equation]
−
[Equation]
( x 1 ) ⊤
[Equation]
x 1 ) −
[Equation]
x 1 )
[Equation]
( f
[Equation]
x
[Equation] [Equation]
f
[Equation]
x
[Equation]
3 −
[Equation]
f ( x 1 )
[Equation]
f ( x −
[Equation]
(cid:21) ≥ log (cid:20)
[Equation]
f ( x
[Equation]
2 ∥ f
( x 1 ) ∥ · ε
[Equation]
3 −
[Equation]
f ( x
[Equation] [Equation]
f ( x
[Equation]
(cid:21) = log (cid:20)
[Equation] [Equation]
( x 1 )
[Equation]
( x
[Equation]
) (cid:21) .
Therefore
[Equation]
we have
[Equation] [Equation]
where ∆ 1 is defined as
[Equation]
ℓ )
E x 1 ∈ A ( x ) x − ∈ A ( 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) k
=
K (cid:88) ℓ =
E
[Equation] [Equation]
[Equation] [Equation]
[Equation] [Equation]
+
K (cid:88) k
=
[Equation]
(cid:88) ℓ =
E
[Equation]
E x 1 ∈ A ( x ) x − ∈ A ( 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) ≤
[Equation]
log
[Equation]
+
[Equation]
(cid:88) k
=
[Equation]
K (cid:88) ℓ =
[Equation]
E
[Equation] [Equation]
[Equation]
E x
[Equation]
A ( x ) x − ∈ A ( x ′ ) (cid:20) 1 + 2 ε (
[Equation] [Equation]
) | f ( x 1 )
[Equation]
f ( x − ) − µ ⊤ k µ ℓ | (cid:21) (mean value theorem, ξ ∈ [ − 1 , 1] ) ≤ R
ε log 2 +
K (cid:88) k
=
K (cid:88) ℓ =
E x , x ′   I (
[Equation]
k
[Equation]
I ( x ′
[Equation]
C ℓ )
E x 1 ∈
[Equation]
 ≤
[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 a detailed proof of the linear reformulation of nearest neighbor classifier in this section.
Proposition E.1 (Linear reformulation of nearest neighbor (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]
holds for any pair of ( ℓ, k ) with ℓ ̸
= k , then the downstream error rate of NN classifier G f
[Equation]
where ρ max ( σ, δ, ε )
=
2(1 − σ )
+
[Equation]
min
[Equation]
p
[Equation]
and ∆
[Equation]
=
[Equation]
∥
[Equation]
r
[Equation]
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 AND CLIP
In this section, we discuss how to apply our framework to MAE (He et al., 2022) and CLIP (Radford et al., 2021).
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 ]
E
[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 shows 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.