Provable Guarantees for Self-Supervised Deep Learning with Spectral Contrastive Loss

Jeff Z. HaoChen, Colin Wei, Adrien Gaidon, Tengyu Ma

Introduction

Recent empirical breakthroughs have demonstrated the effectiveness of self-supervised learning, which trains representations on unlabeled data with surrogate losses and self-defined supervision signals Wu et al. 2018, Oord et al. 2018, Hjelm et al. 2018, Ye et al. 2019, Henaff 2020, Bachman et al. 2019, Tian et al. 2019, Misra and Maaten 2020, Caron et al. 2020, Zbontar et al. 2021, Bardes et al. 2021, Tian et al. 2020a, Chen and He 2020. Self-supervision signals in computer vision are often defined by using data augmentation to produce multiple views of the same image. For example, the recent contrastive learning objectives Arora et al. 2019, Chen et al. 2020a, Chen et al. 2020b, He et al. 2020, Chen et al. 2020c encourage closer representations for augmentations/views of the same natural datapoint than for randomly sampled pairs of data.

Despite the empirical successes, there is a limited theoretical understanding of why self-supervised losses learn representations that can be adapted to downstream tasks, for example, using linear heads. Recent mathematical analyses for contrastive learning by Arora et al. 2019, Tosh et al. 2020, Tosh et al. 2021 provide guarantees under the assumption that two views are somewhat conditionally independent given the label or a hidden variable. However, in practical algorithms for computer vision applications, the two views are augmentations of a natural image and usually exhibit a strong correlation that is difficult to be de-correlated by conditioning. They are not independent conditioned on the label, and we are only aware that they are conditionally independent given the natural image, which is too complex to serve as a hidden variable with which prior works can be meaningfully applied. Thus the existing theory does not appear to explain the practical success of self-supervised learning.

This paper presents a theoretical framework for self-supervised learning without requiring conditional independence. We design a principled, practical loss function for learning neural net representations that resembles state-of-the-art contrastive learning methods. We prove that, under a simple and realistic data assumption, linear classification using representations learned on a polynomial number of unlabeled data samples can recover the ground-truth labels of the data with high accuracy.

The fundamental data property that we leverage is a notion of continuity of the population data within the same class. Though a random pair of images from the same class can be far apart, the pair is often connected by (many) sequences of natural images, where consecutive images in the sequences are close neighbors within the same class. As shown in Figure 1 (images on the left top part), two very different French bulldogs can be connected by a sequence of French bulldogs (which may not be in the training set but are in the support of the population distribution). Prior work Wei et al. 2020 empirically demonstrates this type of connectivity property and uses it in the analysis of pseudolabeling algorithms. This property is more salient when the neighborhood of an example includes many different types of augmentations.

More formally, we define the population augmentation graph, whose vertices are all the augmented data in the population distribution, which can be an exponentially large or infinite set. Two vertices are connected with an edge if they are augmentations of the same natural example. Our main assumption is that for some proper m∈Z+m\in\mathcal{Z}^{+}, we cannot partition the graph into m+1m+1 sub-graphs between which there are few connections (Assumption 3.5). In other words, this intuitively states that there are at most mm clusters in the population augmentation graph. This assumption can be seen as a graph-theoretic version of the continuity assumption on the population distribution. We also assume that there are very few edges across different ground-truth classes (Assumption 3.6). Figure 1 (left) illustrates a realistic scenario where dog and cat are the ground-truth categories, between which edges are very rare. Each breed forms a sub-graph that has sufficient inner connectivity and thus cannot be further partitioned.

Our assumption fundamentally does not require independence of the two views (the positive pairs) conditioned on the class and can allow disconnected sub-graphs within a class. The classes in the downstream task can be also somewhat flexible as long as they are disconnected in the augmentation graph. For example, when the augmentation graph consists of mm disconnected sub-graphs corresponding to fine-grained classes, our assumptions allow the downstream task to have any r≤mr\leq m coarse-grained classes containing these fine-grained classes as a sub-partition. Prior work Wei et al. 2020 on pseudolabeling algorithms essentially requires an exact alignment between sub-graphs and downstream classes (i.e., r=mr=m). They face this limitation because their analysis requires fitting discrete pseudolabels on the unlabeled data. We avoid this difficulty because we consider directly learning continuous representations on the unlabeled data.

We analyze the linear classification performance of the representations learned by minimizing the population spectral contrastive loss. Our main result (Theorem 3.8) shows that when the representation dimension exceeds the maximum number of disconnected sub-graphs, linear classification with learned representations is guaranteed to have a small error. Our theorem reveals a trend that a larger representation dimension is needed when there are a larger number of disconnected sub-graphs. Our analysis relies on novel techniques tailored to linear probe performance, which have not been studied in the spectral graph theory community to the best of our knowledge.

The spectral contrastive loss also works on empirical data. Since our approach optimizes parametric loss functions, guarantees involving the population loss can be converted to finite sample results using off-the-shelf generalization bounds. The end-to-end result (Theorem 4.3) shows that the number of unlabeled examples required is polynomial in the Rademacher complexity of the model family and other relevant parameters, whereas the number of downstream labeled examples only needs to be linear in the representation dimension (which needs to be linear in the number of clusters in the graph). This demonstrates that contrastive learning reduces the amount of labeled examples needed.

In summary, our main theoretical contributions are: 1) we propose a simple contrastive loss motivated by spectral decomposition of the population data graph, 2) under simple and realistic assumptions, we provide downstream classification guarantees for the representation learned by minimizing this loss on population data, and 3) our analysis is easily applicable to deep networks with polynomial unlabeled samples via off-the-shelf generalization bounds. Our theoretical framework can be viewed as containing two stages: we first analyze the population loss and the representation that minimizes it (Section 3), then study the empirical loss where the representation is learned with a neural network with bounded capacity (Section 4).

In addition, we implement and test the proposed spectral contrastive loss on standard vision benchmark datasets. Our algorithm is simple and doesn’t rely on tricks such as stop-gradient which is essential to SimSiam Chen and He 2020. We demonstrate that the features learned by our algorithm can match or outperform several strong baselines (Chen et al. 2020a, Chen et al. 2020c, Chen and He 2020, Grill et al. 2020) when evaluated using a linear probe.

Additional related works

Empirical works on self-supervised learning. Self-supervised learning algorithms have been shown to successfully learn representations that benefit downstream tasks Wu et al. 2018, Oord et al. 2018, Hjelm et al. 2018, Ye et al. 2019, Henaff 2020, Bachman et al. 2019, Tian et al. 2019, Misra and Maaten 2020, Chen et al. 2020c, Chen et al. 2020a, He et al. 2020, Chen et al. 2020b, Caron et al. 2020, Zbontar et al. 2021, Bardes et al. 2021, Tian et al. 2020a, Xie et al. 2019. Many recent self-supervised learning algorithms learn features with siamese networks Bromley et al. 1993, where two neural networks of shared weights are applied to pairs of augmented data. Introducing asymmetry to siamese networks either with a momentum encoder like BYOL Grill et al. 2020 or by stopping gradient propagation for one branch of the siamese network like SimSiam Chen and He 2020 has been shown to effectively avoid collapsing. Contrastive methods Chen et al. 2020a, He et al. 2020, Chen et al. 2020c minimize the InfoNCE loss Oord et al. 2018, where two views of the same data are attracted while views from different data are repulsed.

Theoretical works on self-supervised learning. As briefly discussed in the introduction, several theoretical works have studied self-supervised learning. Arora et al. 2019 provide guarantees for representations learned by contrastive learning on downstream linear classification tasks under the assumption that the positive pairs are conditionally independent given the class label. Theorem 3.3 and Theorem 3.7 of the work of Lee et al. 2020 show that, under conditional independence given the label and/or additional latent variables, representations learned by reconstruction-based self-supervised learning algorithms can achieve small errors in the downstream linear classification task. Lee et al. 2020 generalizes it to approximate conditional independence for Gaussian data and Theorem 4.5 further weakens the assumptions significantly. Tosh et al. 2020 show that contrastive learning representations can linearly recover any continuous functions of the underlying topic posterior under a topic modeling assumption (which also requires conditional independence of the positive pair given the hidden variable). More recently, Theorem 11 of the work of Tosh et al. 2021 provide novel guarantees for contrastive learning under the assumption that there exists a hidden variable hh such that the positive pair (x,x+)(x,x^{+}) are conditionally independent given hh and the random variable p(x∣h)p(x+∣h)/p(x)p(x+)p(x|h)p(x^{+}|h)/p(x)p(x^{+}) has a small variance. However, in practical algorithms for computer vision applications, the two views are two augmentations and thus they are highly correlated. They might be only independent when conditioned on very complex hidden variables such as the original natural image, which might be too complex for the previous results to be meaningfully applied.

We can also compare the assumptions and results on a concrete generative model for the data, our Example 3.10 in Section 3.4, where the data are generated by a mixture of Gaussian or a mixture of manifolds, the label is the index of the mixture, and the augmentations are small Gaussian blurring (i.e., adding Gaussian noise). In this case, the positive pairs (x,x+)(x,x^{+}) are two points that are very close to each other. To the best of our knowledge, applying Theorem 11 of Tosh et al. 2021 to this case with h=xˉh=\bar{x} (the natural datapoint) would result in requiring a large (if not infinite) representation dimension. Because x+x^{+} and xx are very close, the reconstruction-based algorithms in Lee et al. 2020, when used to predict x+x^{+} from xx, will not be able to produce good representations as well. On a technical level, Example 3.10 does not satisfy the requirement regarding the β\beta quantity in Assumption 4.1 of Lee et al. 2020, if (X1,X2)(X_{1},X_{2}) in that paper is equal to (x,x+)(x,x+) here—it requires the label to be correlated with the raw input xx, which is not necessarily true in Example 3.10. This can likely be addressed by using a different X2X_{2}.

On a technical level, to relate prior works’ assumptions to ours, we can consider an almost equivalent version of our assumption (although our proofs do not directly rely on or relate to the discussion below). Let (x,x+)(x,x^{+}) be a positive pair and let p(⋅∣x)p(\cdot|x) be the conditional distribution of x+x^{+} given xx. Starting from x0x_{0}, let us consider a hypothetical Markov chain x0,…,xT,⋯x_{0},\dots,x_{T},\cdots where xtx_{t} is drawn from p(⋅∣xt−1)p(\cdot|x_{t-1}). Our assumption essentially means that this hypothetical Markov chain of sampling neighbors will mix within the same class earlier than it mixes across the entire population (which might not be possible or takes exponential time). More concretely, the assumption that ρ⌊k/2⌋\rho_{\lfloor k/2\rfloor} is large compared to α\alpha in Theorem 3.8 is roughly equivalent to the existence of a (potentially large) TT such that x0x_{0} and xTx_{T} are still likely to have the same label, but are sufficiently independent conditioned on this label or some hidden variable. Roughly speaking, prior works Arora et al. 2019, Tosh et al. 2020, Tosh et al. 2021 assume probabilistic structure about x0x_{0} and x1x_{1} (instead of x0x_{0} and xTx_{T}), e.g., Arora et al. 2019 and Theorem 11 of Tosh et al. 2021 assume that x0x_{0} and x1x_{1} are independent conditioned on the label and/or a hidden variable. Similar Markov chains on augmentated data have also been used in previous work Dao et al. 2019 to study properties of data augmentation.

Several other works (Tsai et al. 2020, Wang and Isola 2020, Tian et al. 2020b, Bansal et al. 2020, Mitrovic et al. 2020) also theoretically study self-supervised learning. The work Tsai et al. 2020 prove that self-supervised learning methods can extract task-relevant information and discard task-irrelevant information, but lacks guarantees for solving downstream tasks efficiently with simple (e.g., linear) models. Tian et al. 2020b study why non-contrastive self-supervised learning methods can avoid feature collapse. Zimmermann et al. 2021 prove that for a specific data generating process, contrastvie learning can learn representations that recover the latent variable. Cai et al. 2021 analyze domain adaptation algorithms for subpopulation shift with a similar expansion condition as Wei et al. 2020 while also allowing disconnected parts within each class, but require access to ground-truth labels during training. In contrast, our algorithm doesn’t need labels during pre-training.

Co-training and multi-view learning are related settings which leverage two distinct “views” (i.e., feature subsets) of the data (Blum and Mitchell 1998, Dasgupta et al. 2002, Balcan et al. 2005). The original co-training algorithms (Blum and Mitchell 1998, Dasgupta et al. 2002) assume that the two views are independent conditioned on the true label and leverage this independence to obtain accurate pseudolabels for the unlabeled data. Balcan et al. 2005 relax the requirement on independent views of co-training, by using an “expansion” assumption, which is closely related to our assumption that ρ⌊k/2⌋\rho_{\lfloor k/2\rfloor} is not too small in Theorem 3.8. Besides recent works (e.g., the work of Tosh et al. 2021), most co-training or multi-view learning algorithms are quite different from the modern contrastive learning algorithms which use neural network parameterization for vision applications.

Our analysis relies on the normalized adjacency matrix (see Section 3.1), which is closely related to the graph Laplacian regularization that has been studied in the setting of semi-supervised learning Zhu et al. 2003, Nadler et al. 2009. In their works, the Laplacian matrix is used to define a regularization term that smooths the predictions on unlabeled data. This regularizer is further added to the supervised loss on labeled data during training. In contrast, we use the normalized adjacency matrix to define the unsupervised training objective in this paper.

Spectral contrastive learning on population data

In this section, we introduce our theoretical framework, the spectral contrastive loss, and the main analysis of the performance of the representations learned on population data.

We next formulate data augmentations. Given a natural data sample xˉ∈X‾\bar{x}\in\overline{\mathcal{X}}, we use A(⋅∣xˉ)\mathcal{A}(\cdot|\bar{x}) to denote the distribution of its augmentations. For instance, when xˉ\bar{x} represents an image, A(⋅∣xˉ)\mathcal{A}(\cdot|\bar{x}) can be the distribution of common augmentations Chen et al. 2020a that includes Gaussian blur, color distortion and random cropping. We use X\mathcal{X} to denote the set of all augmented data, which is the union of supports of all A(⋅∣xˉ)\mathcal{A}(\cdot|\bar{x}) for xˉ∈X‾\bar{x}\in\overline{\mathcal{X}}. As with X‾\overline{\mathcal{X}}, we also assume that X\mathcal{X} is a finite but exponentially large set, and denote N=∣X∣N=|\mathcal{X}|. None of the bounds will depend on NN — it is only defined and assumed to be finite for the ease of exposition.

We denote the error of the representation and the linear head as:

Define the linear probe error as the error of the best possible linear classifier on the representations:

Our approach is based on the central concept of population augmentation graph, denoted by G(X,w)G(\mathcal{X},w), where the vertex set is all augmentation data X\mathcal{X} and ww denotes the edge weights defined below. For any two augmented data x,x′∈Xx,x^{\prime}\in\mathcal{X}, define the weight wxx′w_{xx^{\prime}} as the marginal probability of generating the pair xx and x′x^{\prime} from a random natural data xˉ∼PX‾\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}}:

We emphasize that we only work with the population graph rather than the empirical graph (i.e., the corresponding graph constructed with the empirical dataset as the vertex set). The population graph is very sparse but not empty—many similar images exist in the population. In contrast, the empirical graph would be nearly empty, since two images in the empirical dataset almost never share the same augmentation image. Our analysis will apply to minimizing contrastive loss on an empirical dataset (see Section 4), but not via analyzing the property of the empirical graph. Instead, we will show that contrastive learning on empirical data with parametrized models is similar to decomposing the population graph (see technical discussions in Section 5). This is a key difference between our work and classical spectral clustering work—we only require properties of the population graph rather than the empirical graph.

Given the structure of the population augmentation graph, we apply spectral decomposition to the population graph to construct principled embeddings. The eigenvalue problems are closely related to graph partitioning as shown in spectral graph theory Chung and Graham 1997 for both worst-case graphs Cheeger 1969, Kannan et al. 2004, Louis et al. 2011, Lee et al. 2014 and random graphs McSherry 2001, Lei et al. 2015, Abbe 2017. In machine learning, spectral clustering Ng et al. 2001, Shi and Malik 2000 is a classical algorithm that learns embeddings by eigendecomposition on an empirical distance graph and invoking kk-means on the embeddings.

We will apply eigendecomposition to the population augmentation graph (and then later use linear probe for classification). Let wx=∑x′∈Xwxx′w_{x}=\sum_{x^{\prime}\in\mathcal{X}}w_{xx^{\prime}} be the total weights associated to xx, which is often viewed as an analog of the degree of xx in weighted graph. A central object in spectral graph theory is the so-called normalized adjacency matrix:

2 From spectral decomposition to spectral contrastive learning

The embeddings ux∗u_{x}^{*} obtained by eigendecomposition are nonparametric—a kk-dimensional parameter is needed for every xx—and therefore cannot be learned with a realistic amount of data. The embedding matrix F∗F^{*} cannot be even stored efficiently. Therefore, we will instead parameterize the rows of the eigenvector matrix F∗F^{*} as a neural net function, and assume embeddings ux∗u_{x}^{*} can be represented by f(x)f(x) for some f∈Ff\in\mathcal{F}, where F\mathcal{F} is the hypothesis class containing neural networks. As we’ll show in Section 4, this allows us to leverage the extrapolation power of neural networks and learn the representation on a finite dataset.

Next, we design a proper loss function for the feature extractor ff, such that minimizing this loss could recover F∗F^{*} up to some linear transformation. As we will show in Section 4, the resulting population loss function on ff also admits an unbiased estimator with finite training samples. Let FF be an embedding matrix with uxu_{x} on the xx-th row, we will first design a loss function of FF that can be decomposed into parts about individual rows of FF.

We employ the following matrix factorization based formulation for eigenvectors. Consider the objective

where E(F)\mathcal{E}{(F)} denotes the linear probe performance when the rows of FF are used as embeddings.

The main benefit of objective Lmf(F)\mathcal{L}_{\textup{mf}}({F}) is that it’s based on the rows of FF. Recall that vectors uxu_{x} are the rows of FF. Each entry of FF⊤FF^{\top} is of the form ux⊤ux′u_{x}^{\top}u_{x^{\prime}}, and thus Lmf(F)\mathcal{L}_{\textup{mf}}({F}) can be decomposed into a sum of N2N^{2} terms involving terms ux⊤ux′u_{x}^{\top}u_{x^{\prime}}. Interestingly, if we reparameterize each row uxu_{x} by wx1/2f(x)w_{x}^{1/2}f(x), we obtain a very similar loss function for ff that resembles the contrastive learning loss used in practice (Chen et al. 2020a) as shown below in Lemma 3.2. See Figure 1 (right) for an illustration of the relationship between the eigenvector matrix and the representations learned by minimizing this loss.

We formally define the positive and negative pairs to introduce the loss. Let xˉ∼PX‾\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}} be a random natural datapoint and draw x∼A(⋅∣xˉ)x\sim\mathcal{A}(\cdot|\bar{x}) and x+∼A(⋅∣xˉ)x^{+}\sim\mathcal{A}(\cdot|\bar{x}) independently to form a positive pair (x,x+)(x,x^{+}). Draw xˉ′∼PX‾\bar{x}^{\prime}\sim\mathcal{P}_{\overline{\mathcal{X}}} and x−∼A(⋅∣xˉ′)x^{-}\sim\mathcal{A}(\cdot|\bar{x}^{\prime}) independently with xˉ,x,x+\bar{x},x,x^{+}. We call (x,x−)(x,x^{-}) a negative pair. Though xx and x−x^{-} are simply two independent draws, we call them negative pairs following the literature Arora et al. 2019.

Recall that uxu_{x} is the xx-th row of FF. Let ux=wx1/2f(x)u_{x}=w_{x}^{1/2}f(x) for some function ff. Then, the loss function Lmf(F)\mathcal{L}_{\textup{mf}}({F}) is equivalent to the following loss function for ff, called spectral contrastive loss, up to an additive constant:

We can expand Lmf(F)\mathcal{L}_{\textup{mf}}({F}) and obtain

Notice that the first term is a constant that only depends on the graph but not the variable ff. By the definition of augmentation graph, wxx′w_{xx^{\prime}} is the probability of a random positive pair being (x,x′)(x,x^{\prime}) while wxw_{x} is the probability of a random augmented datapoint being xx. We can hence rewrite the sum of last two terms in Equation (3.2) as Equation (3.2). ∎

We note that spectral contrastive loss is similar to many popular contrastive losses Oord et al. 2018, Chen et al. 2020a, Sohn 2016, Wu et al. 2018. For instance, the contrastive loss in SimCLR Chen et al. 2020a can be rewritten as (with simple algebraic manipulation)

Here xx and x+x^{+} are a positive pair and x1,⋯ ,xnx_{1},\cdots,x_{n} are augmentations of other data. Spectral contrastive loss can be seen as removing f(x)⊤f(x+)f(x)^{\top}f(x^{+}) from the second term, and replacing the log sum of exponential terms with the average of the squares of f(x)⊤f(xi)f(x)^{\top}f(x_{i}). We will show in Section 6 that our loss has a similar empirical performance as SimCLR without requiring a large batch size.

3 Theoretical guarantees for spectral contrastive loss on population data

In this section, we introduce the main assumptions on the data and state our main theoretical guarantee for spectral contrastive learning on population data.

To formalize the idea that GG cannot be partitioned into too many disconnected sub-graphs, we introduce the notions of Dirichlet conductance and sparsest mm-partition, which are standard in spectral graph theory. Dirichlet conductance represents the fraction of edges from SS to its complement:

For a graph G=(X,w)G=(\mathcal{X},w) and a subset S⊆XS\subseteq\mathcal{X}, we define the Dirichlet conductance of SS as

Let G=(X,w)G=(\mathcal{X},w) be the augmentation graph. For an integer i∈[2,∣X∣]i\in[2,|\mathcal{X}|], we define the sparsest ii-partition as

where S1,⋯ ,SiS_{1},\cdots,S_{i} are non-empty sets that form a partition of X\mathcal{X}.

We note that ρi\rho_{i} increases as ii increases. To see this, consider 3≤i≤∣X∣3\leq i\leq|\mathcal{X}|. Let S1,⋯ ,SiS_{1},\cdots,S_{i} be the partition of X\mathcal{X} that minimizes the RHS of Definition 3.4 Define set Si−1′:=Si∪Si−1S_{i-1}^{\prime}:=S_{i}\cup S_{i-1}. It is easy to see that ϕG(Si−1′)=∑x∈Si−1′,x′∉Si−1′wxx′∑x∈Si−1′wx≤∑j=i−1i∑x∈Sj,x′∉Sjwxx′∑j=i−1i∑x∈Sjwx≤max⁡{ϕG(Si−1),ϕG(Si)}\phi_{G}(S_{i-1}^{\prime})=\frac{\sum_{x\in S_{i-1}^{\prime},x^{\prime}\notin S_{i-1}^{\prime}}w_{xx^{\prime}}}{\sum_{x\in S_{i-1}^{\prime}}w_{x}}\leq\frac{\sum_{j=i-1}^{i}\sum_{x\in S_{j},x^{\prime}\notin S_{j}}w_{xx^{\prime}}}{\sum_{j=i-1}^{i}\sum_{x\in S_{j}}w_{x}}\leq\max\{\phi_{G}(S_{i-1}),\phi_{G}(S_{i})\}. Notice that S1,⋯ ,Si−2,Si−1′S_{1},\cdots,S_{i-2},S_{i-1}^{\prime} are i−1i-1 non-empty sets that form a partition of X\mathcal{X}, by Definition 3.4 we have ρi−1≤max⁡{ϕG(S1),⋯ ,ϕG(Si−2),ϕG(Si−1′)}≤max⁡{ϕG(S1),⋯ ,ϕG(Si)}=ρi\rho_{i-1}\leq\max\{\phi_{G}(S_{1}),\cdots,\phi_{G}(S_{i-2}),\phi_{G}(S_{i-1}^{\prime})\}\leq\max\{\phi_{G}(S_{1}),\cdots,\phi_{G}(S_{i})\}=\rho_{i}. When rr is the number of underlying classes, we might expect ρr≈0\rho_{r}\approx 0 since the augmentations from different classes almost compose a disjoint rr-way partition of X\mathcal{X}. However, for i>ri>r, we can expect ρi\rho_{i} to be much larger. For instance, in the extreme case when i=∣X∣=Ni=|\mathcal{X}|=N, every set SjS_{j} is a singleton, which implies that ρN=1\rho_{N}=1. More generally, as we will show later (Lemma 3.9), ρi\rho_{i} can be expected to be at least inverse polynomial in data dimension when ii is larger than the number of underlying semantic classes in the data.

We assume that ρm+1≥ρ\rho_{m+1}\geq\rho. A prototypical case would be that there are at most mm clusters in the population augmentation graph, and each of them cannot be broken into two subsets both with conductance less than ρ\rho.

When there are mm clusters that have sufficient inner connections (corresponding to, e.g., mm semantically coherent subpopulations), we expect ρm+1\rho_{m+1} to be much larger than ρm\rho_{m} because any m+1m+1 partition needs to break one sub-graph into two pieces and incur a large conductance. In other words, suppose the graph is consists of mm clusters, the quantity ρ\rho is characterizing the level of internal connection within each cluster. Furthermore, in many cases we expect ρm+1\rho_{m+1} to be inverse polynomial in dimension. In the running example of Section 3.1 (where augmentation is adding Gaussian noise), ρ\rho is related to the Cheeger constant or the isoperimetric number of the data manifolds, which in many cases is believed to be at least inverse polynomial in dimension (e.g., see Bobkov et al. 1997 for the Cheeger constant of the Gaussian distribution.) Indeed, in Section 3.4 we will formally lowerbound ρm+1\rho_{m+1} by the product of the augmentation strength and the Cheeger constant of the subpopulation distributions (Proposition 3.9), and lowerbound the Cheeger constant by inverse polynomial for concrete settings where the data come from a mixture of manifolds (Theorem 3.11).

Assumption 3.5 also implies properties of the graph spectrum. Recall that γi\gamma_{i} is the ii-th largest eigenvalue of the normalized adjacency matrix A‾\overline{A} and γ1=1\gamma_{1}=1. According to Cheeger’s inequality (Lemma B.4), Assumption 3.5 implies that γ2m≤1−Ω(ρ2/log⁡m)\gamma_{2m}\leq 1-\Omega(\rho^{2}/\log{m}), which suggests that there is a gap between γ1\gamma_{1} and γ2m\gamma_{2m} and will be useful in our analysis.

Next, we formalize the assumption that very few edges cross different ground-truth classes. It turns out that it suffices to assume that the labels are recoverable from the augmentations (which is also equivalent to that two examples in different classes can rarely be augmented into the same point).

Let xˉ∼PX‾\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}} and y(xˉ)y(\bar{x}) be its label. Let the augmentation x∼A(⋅∣xˉ)x\sim\mathcal{A}(\cdot|\bar{x}). We assume that there exists a classifier gg that can predict y(xˉ)y(\bar{x}) given xx with error at most α\alpha. That is, g(x)=y(xˉ)g(x)=y(\bar{x}) with probability at least 1−α1-\alpha.

A small α\alpha in Assumption 3.6 means that different classes are “separated” in the sense that data from different classes have very few (at most O(α)O(\alpha)) shared augmentations. Alternatively, one can think of this assumption as assuming that the augmentation graph can be partitioned into rr clusters each corresponding to augmentations from one class, and there are at most O(α)O(\alpha) edges across the clusters. This is typically true for real-world image data like ImageNet, since for any two images from different classes (e.g., images of a Husky and a Birman cat), using the typical data augmentations such as adding noise and random cropping can rarely (with exponentially small probability) lead to the same augmented image.

Typically, both ρ\rho in Assumption 3.5 and α\alpha in Assumption 3.7 are small positive values that are much less than 1. However, ρ\rho can be much larger than α\alpha. Recall that ρ\rho can be expected to be at least inverse polynomial in dimension. In contrast, α\alpha characterizes the separation between classes and are expected to be exponentially small in typical cases. For example, in the running example of Section 3.1 with Gaussian perturbation augmentation, if σd\sigma\sqrt{d} is smaller than the minimum distance between two subpopulations, we can rarely augment two datapoints from distinct subpopulations into a shared augmentation, and therefore α\alpha is expected to exponentially small. Our analysis below operates in the reasonable regime where ρ2\rho^{2} is larger than α\alpha, which intuitively means that the internal connection within the cluster is bigger than the separation between the clusters.

We also introduce the following assumption which states that some minimizer of the population spectral contrastive loss can be realized by the hypothesis class.

Our main theorem bound from above the linear probe error of the feature learned by minimizing the population spectral contrastive loss. In Theorem 4.3 we extend this result to the case where both the feature and the linear head are learned from empirical datasets.

Assume the representation dimension k≥2rk\geq 2r and Assumption 3.6 holds for α>0\alpha>0. Let F\mathcal{F} be a hypothesis class that satisfies Assumption 3.7 and let fpop∗∈F{f^{*}_{\textup{pop}}}\in\mathcal{F} be a minimizer of L(f)\mathcal{L}({f}). Then, we have

In particular, if Assumption 3.5 also holds and k>2mk>2m, we have E(fpop∗)≤O~(α/ρ2)\mathcal{E}({f^{*}_{\textup{pop}}})\leq\widetilde{O}\left(\alpha/\rho^{2}\right).

Here we use O~(⋅)\widetilde{O}(\cdot) to hide universal constant factors and logarithmic factors in kk. We note that α=0\alpha=0 when augmentations from different classes are perfectly disconnected in the augmentation graph, in which case the above theorem guarantees the exact recovery of the ground truth. Generally, we expect α\alpha to be an extremely (exponentially) small constant independent of kk, whereas ρ⌊k/2⌋\rho_{\lfloor k/2\rfloor} increases with kk and can be at least inverse polynomial when kk is reasonably large, hence much larger than α\sqrt{\alpha}. We characterize the ρk\rho_{k}’s growth on more concrete distributions in the next subsection. When k>2mk>2m, as argued below Assumption 3.6, we expect that α≪ρ2≤ρm+12\alpha\ll\rho^{2}\leq\rho^{2}_{m+1} and thus the error α/ρ2\alpha/\rho^{2} is sufficiently small.

Previous works on graph partitioning Lee et al. 2014, Arora et al. 2009, Leighton and Rao 1999 often analyze the rounding algorithms that conduct clustering based on the representations of unlabeled data and do not analyze the performance of linear probe (which has access to labeled data). These results provide guarantees on the approximation ratio—the ratio between the conductance of the obtained partition to the best partition—which may depend on graph size Arora et al. 2009 that can be exponentially large in our setting. The approximation ratio guarantee does not lead to a guarantee on the representations’ performance on downstream tasks. Our guarantees are on the linear probe accuracy on the downstream tasks and independent of the graph size. We rely on the formulation of the downstream task’s labeling function (Assumption 3.6) as well as a novel analysis technique that characterizes the linear structure of the representations. In Section B, we provide the proof of Theorem 3.8 as well as its more generalized version where k/2k/2 is relaxed to be any constant fraction of kk. A proof sketch of Theorem 3.8 is given in Section 5.1.

4 Provable instantiation of Theorem 3.8 to mixture of manifold data

In this section, we exemplify Theorem 3.8 on examples where the natural data distribution is a mixture of manifolds.

That is, ρm+1\rho_{m+1} is at least linear in the augmentation size σ\sigma and the Cheeger constants of subpopulations.

In many cases, the Cheeger constant is at least inverse polynomial in the data dimension Chen 2021, Lee and Vempala 2016. When the manifolds PiP_{i} are spherical Gaussian with unit identity covariance, the Cheeger constant is Ω(1)\Omega(1)Bobkov et al. 1997, and thus the distribution PX‾\mathcal{P}_{\overline{\mathcal{X}}} in Proposition 3.9 satisfies Assumption 3.5 with ρ≳σ\rho\gtrsim\sigma. Furthermore, when the distribution is transformed by a function with Lipschitzness κ>0\kappa>0, the Cheeger constant changes by a factor at most κ\kappa. Therefore, Proposition 3.9 also applies to a mixture of manifolds setting defined below.

In the rest of this section, we instantiate Theorem 3.8 on a mixture of manifolds example where the data is generated from a Lipschitz transformation of a mixture of Gaussian distributions, and give an error bound for the downstream classification task.

Let the data augmentation of a natural data sample xˉ\bar{x} be xˉ+ξ\bar{x}+\xi where ξ∼N(0,σ2d⋅Id×d)\xi\sim\mathcal{N}(0,\frac{\sigma^{2}}{d}\cdot I_{d\times d}) is isotropic Gaussian noise with 0<σ≲1d0<\sigma\lesssim\frac{1}{\sqrt{d}}. We also assume min⁡i≠j∥μi−μj∥2≳κ⋅log⁡dd′\min_{i\neq j}\left\lVert\mu_{i}-\mu_{j}\right\rVert_{2}\gtrsim\frac{\kappa\cdot\sqrt{\log d}}{\sqrt{d^{\prime}}}.

Let yˉ(x)\bar{y}(x) be the most likely mixture index ii that generates xx: yˉ(x):=arg⁡max⁡iPi(x)\bar{y}(x):=\arg\max_{i}P_{i}(x). The simplest downstream task can have label y(x)=yˉ(x)y(x)=\bar{y}(x). More generally, let r′≤rr^{\prime}\leq r be the number of labels, and the label y(x)∈[r′]y(x)\in[r^{\prime}] in the downstream task be equal to π(yˉ(x))\pi(\bar{y}(x)) where π\pi is a function that maps [r][r] to [r′][r^{\prime}].

We note that the intra-class distance in the latent space is on the scale of Ω(1)\Omega(1), which can be much larger than the distance between class means which is assumed to be ≳κ⋅log⁡dd′\gtrsim\frac{\kappa\cdot\sqrt{\log d}}{\sqrt{d^{\prime}}}. Therefore, distance-based clustering algorithms do not apply. Moreover, in the simple downstream tasks, the label for xx could be just the index of the mixture where xx comes from. We also allow downstream tasks that merge the rr components into r′r^{\prime} labels as long as each mixture component gets the same label. We apply Theorem 3.8 and get the following theorem:

When k≥2r+2k\geq 2r+2, Example 3.10 satisfies Assumption 3.6 with α≤1poly(d)\alpha\leq\frac{1}{\textup{poly}(d)}, and has ρ⌊k/2⌋≳σκd\rho_{\lfloor k/2\rfloor}\gtrsim\frac{\sigma}{\kappa\sqrt{d}}. As a consequence, the error bound is E(fpop∗)≤O~(κ2σ2⋅poly(d))\mathcal{E}({f^{*}_{\textup{pop}}})\leq\widetilde{O}\left(\frac{\kappa^{2}}{\sigma^{2}\cdot\textup{poly}(d)}\right).

The theorem above guarantees small error even when σ\sigma is polynomially small. In this case, the augmentation noise has a much smaller scale than the data (which is at least on the order of 1/κ1/\kappa). This suggests that contrastive learning can non-trivially leverage the structure of the underlying data and learn good representations with relatively weak augmentation. To the best of our knowledge, it is difficult to apply the theorems in previous works (Arora et al. 2019, Lee et al. 2020, Tosh et al. 2020, Tosh et al. 2021, Wei et al. 2020) to this example and get similar guarantees with polynomial dependencies on d,σ,κd,\sigma,\kappa. The work of Wei et al. 2020 can apply to the setting where rr is known and the downstream label is equal to yˉ(x)\bar{y}(x), but cannot handle the case when rr is unknown or when two mixture component can have the same label. We refer the reader to the related work section for more discussions and comparisons. The proof can be found in Section C.2.

Finite-sample generalization bounds

In Section 3, we provide guarantees for spectral contrastive learning on population data. In this section, we show that these guarantees can be naturally extended to the finite-sample regime with standard concentration bounds. In particular, given a unlabeled pretraining dataset {xˉ1,xˉ2,⋯ ,xˉnpre}\{\bar{x}_{1},\bar{x}_{2},\cdots,\bar{x}_{n_{\rm{pre}}}\} with xˉi∼PX‾\bar{x}_{i}\sim\mathcal{P}_{\overline{\mathcal{X}}}, we learn a feature extractor by minimizing the following empirical spectral contrastive loss:

Recall that fpop∗∈F{f^{*}_{\textup{pop}}}\in\mathcal{F} is a minimizer of L(f)\mathcal{L}({f}). The following theorem with proofs in Section D.1 bounds the population loss of a feature extractor trained with finite data:

For some κ>0{\kappa}>0, assume ∥f(x)∥∞≤κ\left\lVert f(x)\right\rVert_{\infty}\leq{\kappa} for all f∈Ff\in\mathcal{F} and x∈Xx\in\mathcal{X}. Let fpop∗∈F{f^{*}_{\textup{pop}}}\in\mathcal{F} be a minimizer of the population loss L(f)\mathcal{L}({f}). Given a random dataset of size npre{n_{\rm{pre}}}, let f^emp∈F{\hat{f}_{\textup{emp}}}\in\mathcal{F} be a minimizer of empirical loss L^npre(f)\widehat{\mathcal{L}}_{{n_{\rm{pre}}}}({f}). Then, when Assumption 3.7 holds, with probability at least 1−δ1-\delta over the randomness of data, we have

where constants c1≲k2κ2+kκc_{1}\lesssim k^{2}{\kappa}^{2}+k{\kappa} and c2≲kκ2+k2κ4c_{2}\lesssim k{\kappa}^{2}+k^{2}{\kappa}^{4}.

The Rademacher complexity usually looks like R^n(F)=R/n\widehat{\mathcal{R}}_{n}(\mathcal{F})=\sqrt{{R}/{n}} where RR measures the complexity of F\mathcal{F} (hence only depends on F\mathcal{F}). This suggests that when κ\kappa is O(1)O(1), the sample complexity for acheiving suboptimality ϵ\epsilon on population loss is O(k4R/ϵ2)O(k^{4}R/\epsilon^{2}). We can apply Theorem 4.1 to any hypothesis class F\mathcal{F} of interest (e.g., deep neural networks) and plug in off-the-shelf Rademacher complexity bounds. For instance, in Section D.2 we give a corollary of Theorem 4.1 when F\mathcal{F} contains deep neural networks with ReLU activation.

The theorem above shows that we can achieve near-optimal population loss by minimizing empirical loss up to some small excess loss. The following theorem characterizes how the error propagates to the linear probe performance mildly under some spectral gap conditions.

In the setting of Theorem 4.1, suppose Assumption 3.5 holds for ρ>0\rho>0, Assumption 3.6 holds for α>0\alpha>0, Assumption 3.7 holds, and the representation dimension k≥max⁡{4r+2,2m}k\geq\max\{4r+2,2m\},. Then, with 1−δ1-\delta probability over the randomness of data, for any f^emp∈F{\hat{f}_{\textup{emp}}}\in\mathcal{F} that minimizes the empirical loss L^npre(f)\widehat{\mathcal{L}}_{{n_{\rm{pre}}}}({f}), we have that

where c≲(kκ+kκ2+1)2c\lesssim(k\kappa+k\kappa^{2}+1)^{2}, and Δγ:=γ⌊3k/4⌋−γk\Delta_{\gamma}:=\gamma_{\lfloor{3k}/4\rfloor}-\gamma_{k} is the eigenvalue gap between the ⌊3k/4⌋\lfloor{3k}/4\rfloor-th and the kk-th eigenvalue.

This theorem shows that the error on the downstream task only grows linearly with the excess loss during pretraining. Roughly speaking, one can think of Δγ\Delta_{\gamma} as on the order of 1−γk1-\gamma_{k}, hence by Cheeger’s inequality it’s larger than ρ2\rho^{2}. When R^npre/2(F)=2R/npre\widehat{\mathcal{R}}_{{n_{\rm{pre}}}/2}(\mathcal{F})=\sqrt{{2R}/{{n_{\rm{pre}}}}} and κ≤O(1)\kappa\leq O(1), we have that the number of unlabeled samples required to achieve ϵ\epsilon downstream error is O(m6R/ϵ2ρ4)O(m^{6}R/\epsilon^{2}\rho^{4}). We can relax Assumption 3.7 to approximate realizability in the sense that F\mathcal{F} contains some sub-optimal feature extractor under the population spectral loss and pay an additional error term in the linear probe error bound. The proof of Theorem 4.2 can be found in Section D.3.

2 Labeled sample complexity for linear probe

The following Theorem 4.3 provides a generalization guarantee for the linear classifier that minimizes capped quadratic loss on a labeled downstream dataset of size ndown{n_{\rm{down}}}. The key challenge of the proof is showing the existence of a small-norm linear head BB that gives small population quadratic loss, which is not obvious from Theorem 4.2 where only small 0-1 error is guaranteed. Given a labeled dataset {(xˉi,y(xˉi))}i=1ndown\{(\bar{x}_{i},y(\bar{x}_{i}))\}_{i=1}^{n_{\rm{down}}} where xˉi∼PX‾\bar{x}_{i}\sim\mathcal{P}_{\overline{\mathcal{X}}} and y(xˉi)y(\bar{x}_{i}) is its label, we sample xi∼A(⋅∣xˉi){x}_{i}\sim\mathcal{A}(\cdot|\bar{x}_{i}) for i∈[ndown]i\in[{n_{\rm{down}}}]. Given a norm bound Ck>0C_{k}>0, we learn a linear probe B^\widehat{B} by minimizing the capped quadratic loss subject to a norm constraint:

In the setting of Theorem 4.2, choose Ck>0C_{k}>0 such that Ck≥2(k+1)γkC_{k}\geq\frac{2(k+1)}{\gamma_{k}}. Then, with probability at least 1−δ1-\delta over the randomness of data, for any f^emp∈F{\hat{f}_{\textup{emp}}}\in\mathcal{F} that minimizes the empirical pre-training loss L^npre(f)\widehat{\mathcal{L}}_{{n_{\rm{pre}}}}({f}) and a linear head B^\widehat{B} learned from Equation (10), we have

Here the first term is an error caused by the property fo the population data, which is unavoidable even with infinite pretraining and downstream samples (but it can be small as argued in Section 3.3). The second term is caused by finite pretraining samples, and the third term is caused by finite samples in the linear classification on the downstream task.

Typically, the Rademacher complexity is roughly R^npre/2(F)=2R/npre\widehat{\mathcal{R}}_{{n_{\rm{pre}}}/2}(\mathcal{F})=\sqrt{{2R}/{{n_{\rm{pre}}}}} where RR is captures the complexity of the model architecture. Thus, to achieve final linear probe error no more than O(ϵ)O(\epsilon), we would need to select kk such that αρ⌊k/2⌋2⋅log⁡k≤ϵ\frac{\alpha}{\rho_{\lfloor k/2\rfloor}^{2}}\cdot\log k\leq\epsilon, and we need poly(k,1Δγ,R,1ϵ)\textup{poly}(k,\frac{1}{\Delta_{\gamma}},R,\frac{1}{\epsilon}) pretraining samples and poly(k,r,1γk,1ϵ)\textup{poly}(k,r,\frac{1}{\gamma_{k}},\frac{1}{\epsilon}) downstream samples.

When r<kr<k, the eigengap Δγ\Delta_{\gamma} is on the order of 1−γk1-\gamma_{k} which is larger than ρ2\rho^{2} by Cheeger inequality. Recall that ρ\rho is at least inverse polynomial in dd as argued in Section 3.4, one can expect 1Δγ\frac{1}{\Delta_{\gamma}} to be at most poly(d)\textup{poly}(d). On the other hand, γk≈1\gamma_{k}\approx 1 so 1γk\frac{1}{\gamma_{k}} can be thought of as a constant. Thus, the final required number of pretraining samples is npre=poly(k,d,R,1ϵ){n_{\rm{pre}}}=\textup{poly}(k,d,R,\frac{1}{\epsilon}) and number of downstream samples is ndown=poly(r,k,1ϵ){n_{\rm{down}}}=\textup{poly}(r,k,\frac{1}{\epsilon}). We note that the downstream sample complexity doesn’t depend on the complexity of the hypothesis class RR, suggesting that pretraining helps reduce the sample complexity of the supervised downstream task.

The proof of Theorem 4.3 is in Section E.

Analysis Framework and Proof Sketch

As discussed before and suggested by the structured of Section 3 and 4, our analysis framework decompose the problem into a key step about the population cases (Section 3) and a few other somewhat standard steps that link empirical losses to population losses (Section 4). As depicted in Figure 2, the core step (Theorem 3.8, or its extension Theorem 4.2) is to show that a small population pretraining loss implies the existence of a linear classifier for the downstream task, that is, a small minimal downstream loss.

We first remark that a feature of our analysis framework is that we link the population pretraining data case to the finite sample case by showing the empirical and population pretraining losses are similar when the feature extractors are a parameterized family of models with capacity bounds (the first arrow in Figure 2). Hypothetically, suppose such a connection between population and empirical data case was built through the relationship between the population and empirical graphs, e.g., by proving that the empirical graph has similar spectral properties as the population graph, then the sample complexity will be exponential. Intuitively, this is because the population graph is very sparse, and the empirical graph is with high probability empty if the number of samples is only polynomial in dimension (e.g. consider the case when the augmentation simply adds small perturbation, as in the running example in Section 3.1). The empirical graph essentially follows the well-studied random geometric graph model (Penrose 2003), and tends to have no structure in high dimension Bubeck et al. 2016, Liu et al. 2021, Brennan et al. 2020. The fundamental difference between this hypothetical and our framework is that the empirical graph’s definition does not involve any parameterization, and thus the resemblance between the empirical and population graphs does not leverage the extrapolation (or inductive bias) of the model parameterization as our framework does for the pretraining losses.

We note that the inductive bias of the parameterized model is indeed used in the analysis for finite-sample case. We assume that the model family F\mathcal{F} can express the eigenfunctions/eigenvectors of the graph (Assumption 3.7) and also implicitly assume bounds on its Rademacher complexity (in Theorem 4.3).

Once we obtained that the existence of a linear classifier, the remaining steps (the third and fourth arrows in Figure 2) follow from standard supervised learning theory.

In the rest of this section, we will give a proof sketch of the population case, which is the more challenging step.

In this section, we give a proof sketch of Theorem 3.8 in a simplified binary classification setting where there are only two classes in the downstream task.

Recall that NN is the size of X\mathcal{X}. Recall that wxw_{x} is the total weight associated with an augmented datapoint x∈Xx\in\mathcal{X}, which can also be thought of as the probability mass of xx as a randomly sampled augmented datapoint. In the scope of this section, for demonstrating the key idea, we also assume that xx has uniform distribution, i.e., wx=1Nw_{x}=\frac{1}{N} for any x∈Xx\in\mathcal{X}.

Let L≜I−A‾\mathcal{L}\triangleq{I}-\overline{A} be the normalized Laplacian matrix. Then, viv_{i}’s are the kk smallest unit-norm eigenvectors of L\mathcal{L} with eigenvalues λi=1−γi\lambda_{i}=1-\gamma_{i}. Elementary derivations can give a well-known, important property of the Laplacian matrix LL: the quadratic form g⃗⊤Lg⃗\vec{g}^{\top}L\vec{g} captures the amount of edges across the two groups that are defined by the binary vector g⃗\vec{g} (Chung and Graham 1997, section 1.2):

With slight abuse of notation, suppose (x,x+)(x,x^{+}) is the random variable for a positive pair. Using that ww is the density function for the positive pair and the simplification that wx=1/Nw_{x}=1/N, we can rewrite equation (12) as

Next, we use equation (14) to link g⃗\vec{g} to the eigenvectors of LL. Let λk+1≤…λN\lambda_{k+1}\leq\dots\lambda_{N} be the rest of eigenvalues with unit-norm eigenvectors vk+1,…,vNv_{k+1},\dots,v_{N}. Let Π≜∑i=1kvivi⊤\Pi\triangleq\sum_{i=1}^{k}v_{i}v_{i}^{\top} and Π⊥≜∑i=k+1Nvivi⊤\Pi_{\perp}\triangleq\sum_{i=k+1}^{N}v_{i}v_{i}^{\top} be the projection operators onto the subspaces spanned by the first kk and the last N−kN-k eigenvectors, respectively. Equation (14) implies that g⃗\vec{g} has limited projection to the subspace of Π⊥\Pi_{\perp}:

where the first inequality follows from dropping the ∥(Πg⃗)⊤LΠg⃗∥22\|(\Pi\vec{g})^{\top}L\Pi\vec{g}\|_{2}^{2} and using Π⊥LΠ=0\Pi_{\perp}L\Pi=0, and the second inequality is because that Π⊥\Pi_{\perp} only contains eigenvectors with eigenvalue at least λk+1\lambda_{k+1}.

By higher-order Cheeger inequality (see Lemma B.4), we have that λk+1≳ρ⌈k/2⌉2\lambda_{k+1}\gtrsim\rho_{\lceil k/2\rceil}^{2}. Then, we obtain the mean-squared error bound:

Experiments

We test spectral contrastive learning on benchmark vision datasets. We minimize the empirical spectral contrastive loss with an encoder network ff and sample fresh augmentation in each iteration. The pseudo-code for the algorithm and more implementation details can be found in Section A.

Encoder / feature extractor. The encoder ff contains three components: a backbone network, a projection MLP and a projection function. The backbone network is a standard ResNet architecture. The projection MLP is a fully connected network with BN applied to each layer, and ReLU activation applied to each except for the last layer. The projection function takes a vector and projects it to a sphere ball with radius μ\sqrt{\mu}, where μ>0\mu>0 is a hyperparameter that we tune in experiments. We find that using a projection MLP and a projection function improves the performance.

Linear evaluation protocol. Given the pre-trained encoder network, we follow the standard linear evaluation protocol Chen and He 2020 and train a supervised linear classifier on frozen representations, which are from the ResNet’s global average pooling layer.

Results. We report the accuracy on CIFAR-10/100 Krizhevsky and Hinton 2009 and Tiny-ImageNet Le and Yang 2015 in Table 1. Our empirical results show that spectral contrastive learning achieves better performance than two popular baseline algorithms SimCLR Chen et al. 2020a and SimSiam Chen and He 2020. In Table 2 we report results on ImageNet Deng et al. 2009 dataset, and show that our algorithm achieves similar performance as other state-of-the-art methods. We note that our algorithm is much more principled than previous methods and doesn’t rely on large batch sizes (SimCLR Chen et al. 2020a), momentum encoders (BYOL Grill et al. 2020 and MoCo He et al. 2020) or additional tricks such as stop-gradient (SimSiam Chen and He 2020).

Conclusion

In this paper, we present a novel theoretical framework of self-supervised learning and provide provable guarantees for the learned representation on downstream linear classification tasks. We hope the framework could facilitate future theoretical analyses of self-supervised pretraining losses and inspire new methods. It does not capture the potential implicit bias of optimizers but does take into account the inductive bias of the models. By abstracting away the effect of optimization, we can focus on the effect of pretraining losses and their interaction with the structure of the population data. Future directions may include designing better pretraining losses and analyzing more fine-grained properties of the learned representations (e.g., as in recent follow-up works Shen et al. 2022, HaoChen et al. 2022), by potentially leveraging more advanced techniques from spectral graph theory.

Acknowledgements

We thank Margalit Glasgow, Ananya Kumar, Jason D. Lee, Sang Michael Xie, and Guodong Zhang for helpful discussions. CW acknowledges support from an NSF Graduate Research Fellowship. TM acknowledges support of Google Faculty Award and NSF IIS 2045685. We also acknowledge the support of HAI and the Google Cloud. Toyota Research Institute ("TRI") provided funds to assist the authors with their research but this article solely reflects the opinions and conclusions of its authors and not TRI or any other Toyota entity.

References

Appendix A Experiment details

The pseudo-code for our empirical algorithm is summarized in Algorithm 1.

Our results with different hyperparameters on CIFAR-10/100 and Tiny-ImageNet are listed in Table 3.

Additional details about the encoder. For the backbone network, we use the CIFAR variant of ResNet18 for CIFAR-10 and CIFAR-100 experiments and use ResNet50 for Tiny-ImageNet and ImageNet experiments. For the projection MLP, we use a 2-layer MLP with hidden and output dimensions 1000 for CIFAR-10, CIFAR100, and Tiny-ImageNet experiments. We use a 3-layer MLP with hidden and output dimension 8192 for ImageNet experiments. We set μ=10\mu=10 in the ImageNet experiment, and set μ∈{1,3,10}\mu\in\{1,3,10\} for the CIFAR-10/100 and Tiny-ImageNet experiments.

Training the encoder. We train the neural network using SGD with momentum 0.9. The learning rate starts at 0.05 and decreases to 0 with a cosine schedule. On CIFAR-10/100 and Tiny-ImageNet we use weight decay 0.0005 and train for 800 epochs with batch size 512. On ImageNet we use weight decay 0.0001 and train for 100 epochs with batch size 384. We use 1 GTX 1080 GPU for CIFAR-10/100 and Tiny-ImageNet experiments, and use 8 GTX 1080 GPUs for ImageNet experiments.

Linear evaluation protocol. We train the linear head using SGD with batch size 256 and weight decay 0 for 100 epochs, learning rate starts at 30.0 and is decayed by 10x at the 60th and 80th epochs.

Image transformation details. We use the same augmentation strategy as described in Chen and He 2020.

Appendix B Proofs for Section 3

We first prove a more generalized version of Theorem 3.8 in section B.1, and then prove Theorem 3.8 in Section B.2.

For the proof we will follow the convention in literature Lee et al. 2014 and define the normalized Laplacian matrix as follows:

Let G=(X,w)G=(\mathcal{X},w) be the augmentation graph defined in Section 3.1. The normalized Laplacian matrix of the graph is defined as L=I−D−1/2AD−1/2\mathcal{L}={I}-{D}^{-1/2}{A}{D}^{-1/2}, where A{A} is the adjacency matrix with Axx′=wxx′{A}_{xx^{\prime}}=w_{xx^{\prime}} and D{D} is a diagonal matrix with Dxx=wx{D}_{xx}=w_{x}.

It is easy to see that L=I−A‾\mathcal{L}=I-\overline{A} where A‾\overline{A} is the normalized adjacency matrix defined in Section 3.1. Therefore, when λi\lambda_{i} is the ii-th smallest eigenvalue of L\mathcal{L}, 1−λi1-\lambda_{i} is the ii-th largest eigenvalue of A‾\overline{A}.

We call a function defined on augmented data y^:X→[r]\hat{y}:\mathcal{X}\rightarrow[r] an extended labeling function. Given an extended labeling function, we define the following quantity that describes the difference between extended labels of two augmented data of the same natural datapoint:

We also define the following quantity that describes the difference between extended label of an augmentated datapoint and the ground truth label of the corresponding natural datapoint:

Recall the spectral contrastive loss defined in Section 3.2 is:

We first state a more general version of Theorem 3.8 as follows.

where y⃗(xˉ)\vec{{y}}(\bar{x}) is the one-hot embedding of y(xˉ){y}(\bar{x}) and ρk′\rho_{k^{\prime}} is the sparsest mm-partition defined in Definition 3.4. Furthermore, the error of the linear probe predictor can be bounded by

Also, if we let λi\lambda_{i} be the ii-th smallest eigenvalue of the normalized Laplacian matrix of the graph of the augmented data, we can find a matrix B∗B^{*} satisfying the above equations with norm bound ∥B∗∥F≤1/(1−λk)\left\lVert{B}^{*}\right\rVert_{F}\leq 1/(1-\lambda_{k}).

We provide the proof for Theorem B.2 below.

Let λ1,λ2,⋯ ,λk,λk+1\lambda_{1},\lambda_{2},\cdots,\lambda_{k},\lambda_{k+1} be the k+1k+1 smallest eigenvalues of the Laplacian matrix LL. The following theorem gives a theoretical guarantee similar to Theorem B.2 except for that the bound depends on λk+1\lambda_{k+1}:

where y⃗(xˉ)\vec{{y}}(\bar{x}) is the one-hot embedding of y(xˉ){y}(\bar{x}). Furthermore, the error can be bounded by

We defer the proof of Theorem B.3 to Section B.3.

To get rid of the dependency on λk+1\lambda_{k+1}, we use following higher-order Cheeger’s inequality from Louis and Makarychev 2014.

Let G=(V,w)G=(V,w) be a weight graph with ∣V∣=N|V|=N. Then, for any t∈[N]t\in[N] and ζ>0\zeta>0 such that (1+ζ)t∈[N](1+\zeta)t\in[N], there exists a partition S1,S2,⋯ ,StS_{1},S_{2},\cdots,S_{t} of VV with

where ϕG(⋅)\phi_{G}(\cdot) is the Dirichlet conductance defined in Definition 3.3.

Now we prove Theorem B.2 by combining TheoremB.3 and Lemma B.4.

Let G=(X,w)G=(\mathcal{X},w) be the augmentation graph. In Lemma B.4 let (1+ζ)t=k+1(1+\zeta)t=k+1 and t=k′t=k^{\prime} we have: there exists partition S1,⋯ ,Sk′⊂XS_{1},\cdots,S_{k^{\prime}}\subset\mathcal{X} such that ϕG(Si)≲poly(1/ζ)λk+1log⁡(k+1)\phi_{G}(S_{i})\lesssim\textup{poly}(1/\zeta)\sqrt{\lambda_{k+1}\log{(k+1)}} for ∀i∈[k′]\forall i\in[k^{\prime}]. By Definition 3.4, we have ρk′≤max⁡i∈[k′]ϕG(Si)≲poly(1/ζ)λk+1log⁡(k+1)\rho_{k^{\prime}}\leq\max_{i\in[k^{\prime}]}\phi_{G}(S_{i})\lesssim\textup{poly}(1/\zeta)\sqrt{\lambda_{k+1}\log{(k+1)}}, which leads to 1λk+1≲poly(1/ζ)⋅log(k+1)⋅1ρk′2\frac{1}{\lambda_{k+1}}\lesssim\textup{poly}(1/\zeta)\cdot{log(k+1)}\cdot\frac{1}{\rho_{k^{\prime}}^{2}}. Plugging this bound to Theorem B.3 finishes the proof. ∎

B.2 Proof of Theorem 3.8

We will use the following lemma which gives a connection between ϕy^\phi^{\hat{y}}, Δ(y,y^)\Delta(y,\hat{y}) and Assumption 3.6.

Let G=(X,w)G=(\mathcal{X},w) be the augmentation graph, rr be the number of underlying classes. Let S1,S2,⋯ ,SrS_{1},S_{2},\cdots,S_{r} be the partition induced by the classifier gg in Assumption 3.6. Then, there exists an extended labeling function y^\hat{y} such that

We define function y^:X→[r]\hat{y}:\mathcal{X}\rightarrow[r] as follows: for an augmented data x∈Xx\in\mathcal{X}, we use function y^(x)\hat{y}(x) to represent the index of set that xx is in, i.e., x∈Sy^(x)x\in S_{\hat{y}(x)}. By Assumption 3.6 it is easy to see Δ(y,y^)≤α\Delta(y,\hat{y})\leq\alpha. On the other hand, we have

Here the inequality is because when y^(x)≠y^(x′)\hat{y}(x)\neq\hat{y}(x^{\prime}), there must be y^(x)≠y(xˉ)\hat{y}(x)\neq y(\bar{x}) or y^(x′)≠y(xˉ)\hat{y}(x^{\prime})\neq y(\bar{x}). ∎

Now we give the proof of Theorem 3.8 using Lemma B.5 and Theorem B.2.

Let S1,S2,⋯ ,SrS_{1},S_{2},\cdots,S_{r} be the partition of X\mathcal{X} induced by the classifier gg given in Assumption 3.6. Define function y^:X→[r]\hat{y}:\mathcal{X}\rightarrow[r] as follows: for an augmented datapoint x∈Xx\in\mathcal{X}, we use function y^(x)\hat{y}(x) to represent the index of set that xx is in, i.e., x∈Sy^(x)x\in S_{\hat{y}(x)}. Let k′=⌊k2⌋k^{\prime}=\lfloor\frac{k}{2}\rfloor in Theorem B.2, we have Pr⁡xˉ∼PX‾,x∼A(⋅∣xˉ)(gfpop∗,B∗(x)≠y(xˉ))≲log⁡(k)⋅ϕy^ρ⌊k/2⌋2+Δ(y,y^).\Pr_{\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}},{x}\sim\mathcal{A}(\cdot|\bar{x})}\left(g_{{f^{*}_{\textup{pop}}},{B}^{*}}({x})\neq y(\bar{x})\right)\lesssim\log(k)\cdot\frac{\phi^{\hat{y}}}{\rho_{\lfloor k/2\rfloor}^{2}}+\Delta(y,\hat{y}). By Lemma B.5 we have ϕy^≤2α\phi^{\hat{y}}\leq 2\alpha and Δ(y,y^)≤α\Delta(y,\hat{y})\leq\alpha, so we have Pr⁡xˉ∼PX‾,x∼A(⋅∣xˉ)(gfpop∗,B∗(x)≠y(xˉ))≲αρ⌊k/2⌋2⋅log⁡(k).\Pr_{\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}},{x}\sim\mathcal{A}(\cdot|\bar{x})}\left(g_{{f^{*}_{\textup{pop}}},{B}^{*}}({x})\neq y(\bar{x})\right)\lesssim\frac{\alpha}{\rho_{\lfloor k/2\rfloor}^{2}}\cdot\log(k). Notice that by definition of ensembled linear probe predictor, gˉfpop∗,B∗(xˉ)≠y(xˉ)\bar{g}_{{f^{*}_{\textup{pop}}},{B}^{*}}(\bar{x})\neq y(\bar{x}) happens only if more than half of the augmentations of xˉ\bar{x} predicts differently from y(xˉ)y(\bar{x}), so we have Pr⁡xˉ∼PX‾(gˉfpop∗,B∗(xˉ)≠y(xˉ))≤2Pr⁡xˉ∼PX‾,x∼A(⋅∣xˉ)(gfpop∗,B∗(x)≠y(xˉ))≲αρ⌊k/2⌋2⋅log⁡(k)\Pr_{\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}}}\left(\bar{g}_{{f^{*}_{\textup{pop}}},{B}^{*}}(\bar{x})\neq y(\bar{x})\right)\leq 2\Pr_{\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}},{x}\sim\mathcal{A}(\cdot|\bar{x})}\left(g_{{f^{*}_{\textup{pop}}},{B}^{*}}({x})\neq y(\bar{x})\right)\lesssim\frac{\alpha}{\rho_{\lfloor k/2\rfloor}^{2}}\cdot\log(k). ∎

B.3 Proof of Theorem B.3

The proof of Theorem B.3 contains two steps. First, we show that when the feature extractor is composed of the minimal eigenvectors of the normalized Laplacian matrix LL, we can achieve good linear probe accuracy. Then we show that minimizing L(f)\mathcal{L}({f}) gives us a feature extractor equally good as the eigenvectors.

For the first step, we use the following lemma which shows that the smallest eigenvectors of L\mathcal{L} can approximate any function on X\mathcal{X} up to an error proportional to the Rayleigh quotient of the function.

We can decompose the vector u{u} in the eigenvector basis as:

We also need the following claim about the Rayleigh quotient R(u)R({u}) when u{u} is a vector defined by an extended labeling function y^\hat{y}.

To see the connection between the feature extractor minimizing the population spectral contrastive loss L(f)\mathcal{L}({f}) and the feature extractor corresponding to eigenvectors of the Laplacian matrix, we use the following lemma which states that the minimizer of the matrix approximation loss defined in Section 3.2 is equivalent to the minimizer of population spectral contrastive loss up to a data-wise scaling.

Recall that the definition of spectral contrastive loss is

where (x,x+)(x,x^{+}) is a random positive pair, (x,x−)(x,x^{-}) is a random negative pair. We can rewrite the spectral contrastive loss as

Compare Equation (B.3) and Equation (21), we see they only differ by a constant, which finishes the proof. ∎

Note that the minimizer of matrix approximation loss is exactly the largest eigenvectors of I−L{I}-{L} (also the smallest eigenvectors of L{L}) due to Eckart–Young–Mirsky theorem, Lemma B.8 indicates that the minimizer of L(f)\mathcal{L}({f}) is equivalent to the smallest eigenvectors of L\mathcal{L} up to data-wise scaling.

The following claim shows the relationship between quadratic loss and prediction error.

where y⃗\vec{y} is the one-hot embedding of yy.

When y≠gf,B(x)y\neq g_{f,B}(x), by the definition of gf,Bg_{f,B} we know that there exists another y′≠yy^{\prime}\neq y such that (Bf(x))y′≥(Bf(x))y(Bf(x))_{y^{\prime}}\geq(Bf(x))_{y}. In this case,

Now we are ready to prove Theorem B.3 by combining Lemma B.6, Claim B.7, Lemma B.8 and Claim B.9.

Now we come back to the feature extractor fpop∗{f^{*}_{\textup{pop}}} that minimizes the spectral contrastive loss function L(f)\mathcal{L}({f}). By Lemma B.8, matrix F∗{F}^{*} that contains wx⋅fpop∗(x)\sqrt{w_{x}}\cdot{f^{*}_{\textup{pop}}}(x) as its xx-th row is a minimizer of Lmf(F)\mathcal{L}_{\textup{mf}}({F}). By Eckard-Young-Mirsky theorem, we have

and let y⃗(xˉ)\vec{{y}}(\bar{x}) be the one-hot embedding of y(xˉ){y}(\bar{x}), y^⃗(x)\vec{\hat{y}}({x}) be the one-hot embedding of y^(x)\hat{y}({x}), we have

To bound the error rate, we first notice that Claim B.9 tells us that for any x∈X{x}\in\mathcal{X},

Now we bound the error rate on X\mathcal{X} as follows:

Appendix C Proofs for Section 3.4

Let BσB_{\sigma} be the uniform distribution over a ball with radius σ\sigma. Let S1,S2,⋯ ,Sm+1S_{1},S_{2},\cdots,S_{m+1} be a partition of the Euclidean space. There must be some i∈[m+1]i\in[m+1] such that Pr⁡x∼Pj,ξ∼Bσ[x+ξ∈Si]≤12\Pr_{{x}\sim P_{j},\xi\sim B_{\sigma}}[{x}+\xi\in S_{i}]\leq\frac{1}{2} for all j∈[m]j\in[m]. Thus, we know that

On one hand, suppose ∫x∉RPj(x)P(Si∣x)dx≥12Pr⁡x∼Pj,ξ∼Bσ[x+ξ∈Si]\int_{x\notin R}P_{j}(x)P(S_{i}|x)dx\geq\frac{1}{2}\Pr_{{x}\sim P_{j},\xi\sim B_{\sigma}}[{x}+\xi\in S_{i}], we can lower bound the numerator in the RHS of Equation (29) as

hence the RHS of Equation (29) is at least 1/61/6.

On the other hand, suppose ∫x∉RPj(x)P(Si∣x)dx<12Pr⁡x∼Pj,ξ∼Bσ[x+ξ∈Si]\int_{x\notin R}P_{j}(x)P(S_{i}|x)dx<\frac{1}{2}\Pr_{{x}\sim P_{j},\xi\sim B_{\sigma}}[{x}+\xi\in S_{i}], we have

hence the denominator of the RHS of Equation (29) can be upper bounded by

For two Gaussian distributions with variance σ2⋅Id×d\sigma^{2}\cdot\mathcal{I}_{d\times d} and centers at most σ6\frac{\sigma}{6} far from each other, their TV-distance is at most 16\frac{1}{6} (see the first equation on Page 5 of Devroye et al. 2018), hence for any x∈N(R)x\in N(R), we have P(Si∣x)≥23−16=12P(S_{i}|x)\geq\frac{2}{3}-\frac{1}{6}=\frac{1}{2}. We can now lower bound the numerator in the RHS of Equation (29) as:

Notice that Pr⁡x∼Pj,ξ∼Bσ[x+ξ∈Si]≤12\Pr_{{x}\sim P_{j},\xi\sim B_{\sigma}}[{x}+\xi\in S_{i}]\leq\frac{1}{2} and by the definition of RR, we know ∫x∈RPj(x)dx≤34\int_{x\in R}P_{j}(x)dx\leq\frac{3}{4}, thus

Combine Equation (34), Equation (C.1) and Equation (37) gives:

Notice that (using the definition of surface area (Guggenheimer 1977, chapter 4))

we have that as σ→0+\sigma\rightarrow 0^{+},

C.2 Proof of Theorem 3.11

In this section, we give a proof of Theorem 3.11.

The following lemma shows that the augmented graph for Example 3.10 satisfies Assumption 3.6 with some bounded α\alpha.

In the setting of Theorem 3.11, the data distribution satisfies Assumption 3.6 with α≤1poly(d′)\alpha\leq\frac{1}{\textup{poly}(d^{\prime})}.

For any z∼N(μi,1d′⋅Id′×d′)z\sim\mathcal{N}(\mu_{i},\frac{1}{d^{\prime}}\cdot I_{d^{\prime}\times d^{\prime}}) and any j≠ij\neq i, by the tail bound of gaussian distribution we have

Also, for ξ∼N(0,1d⋅Id×d)\xi\sim\mathcal{N}(0,\frac{1}{d}\cdot I_{d\times d}), when σ≤1d\sigma\leq\frac{1}{\sqrt{d}} we have

Notice that ∥Q−1(Q(z)+ξ)−z∥2≤κ∥ξ∥\left\lVert Q^{-1}(Q(z)+\xi)-z\right\rVert_{2}\leq\kappa\left\lVert\xi\right\rVert, we can set ∥μi−μj∥≳κlog⁡dd\left\lVert\mu_{i}-\mu_{j}\right\rVert\gtrsim\kappa\frac{\sqrt{\log d}}{\sqrt{d}}. Therefore, when ∥μi−μj∥≳κlog⁡dd′\left\lVert\mu_{i}-\mu_{j}\right\rVert\gtrsim\kappa\frac{\sqrt{\log d}}{\sqrt{d^{\prime}}} we can combine the above two cases and have

We use the following lemma to give a lower bound for the sparest mm-partition of the augmentation graph in Example 3.10.

In the setting of Theorem 3.11, for any k′>rk^{\prime}>r and τ>0\tau>0, we have

with Φd(z):=Pr⁡ξ∼N(0,1dId×d)(∥ξ∥2≤z)\Phi_{d}(z):=\Pr_{\xi\sim\mathcal{N}(0,\frac{1}{d}I_{d\times d})}(\left\lVert\xi\right\rVert_{2}\leq z), and

with Φ(z):=∫−∞ze−u2/22πdu.\Phi(z):=\int_{-\infty}^{z}\frac{e^{-u^{2}/2}}{\sqrt{2\pi}}du.

The proof of Lemma C.2 can be found in Section C.3. Now we give the proof of Example 3.11.

The result on α\alpha is directly from Lemma C.1. By concentration inequality, there must exists some universal constant C>0C>0 such that for any d≥Cd\geq C, we have 1−Φd(32)≤131-\Phi_{d}(\sqrt{\frac{3}{2}})\leq\frac{1}{3}. When this happens, we have Φd−1(23)≤32\Phi_{d}^{-1}(\frac{2}{3})\leq\sqrt{\frac{3}{2}}. Since for d≤Cd\leq C we can just treat dd as constant, we have Φd−1(23)≲1\Phi_{d}^{-1}(\frac{2}{3})\lesssim 1. Set τ=σ/d\tau=\sigma/d in Lemma C.2, we have ρk′≳σκd\rho_{k^{\prime}}\gtrsim\frac{\sigma}{\kappa\sqrt{d}}. Set k′=⌊k/2⌋k^{\prime}=\lfloor k/2\rfloor, we apply Theorem 3.8 and get the bound we need. ∎

C.3 Proof of Lemma C.2

In this section we give a proof for Lemma C.2. We first introduce the following claim which states that for a given subset of augmented data, any two data close in L2L_{2} norm cannot have a very different chance of being augmented into this set.

with Φd(z):=Pr⁡ξ∼N(0,1d⋅Id×d)(∥ξ∥2≤z)\Phi_{d}(z):=\Pr_{\xi\sim\mathcal{N}(0,\frac{1}{d}\cdot I_{d\times d})}(\left\lVert\xi\right\rVert_{2}\leq z).

By the definition of augmentation, we know

By the definition of cσc_{\sigma}, we have

Since Pr⁡(S∣x)≥23\Pr(S|x)\geq\frac{2}{3} by assumption, we have

Now we can bound the quanity of our interest:

Let S1,⋯ ,Sk′S_{1},\cdots,S_{k^{\prime}} be the disjoint sets that gives ρk′\rho_{k^{\prime}} in Definition 3.4. First we notice that when k′>rk^{\prime}>r, there must exist t∈[k′]t\in[k^{\prime}] such that for all i∈[r]i\in[r], we have

WLOG, we assume j=1j=1 minimizes the RHS of Equation (42), so we only need to prove

where the second inequality is by Claim C.3. Notice that

where we use Equation (41). Define set R~:=Q−1(R)\widetilde{R}:=Q^{-1}(R) be the set in the ambient space corresponding to RR. Define

Due to QQ being κ\kappa-bi-lipschitz, it is easy to see N~(R~)⊆Q−1(N(R))\widetilde{N}(\widetilde{R})\subseteq Q^{-1}\left(N(R)\right). According to the Gaussian isoperimetric inequality Bobkov et al. 1997, we have

with Φ(⋅)\Phi(\cdot) is the Gaussian CDF function defined as

By Equation (C.3), either case 1 or case 2 holds. Combining case 1 and case 2, we have

Appendix D Proofs for Section 4

We restate the empirical spectral contrastive loss defined in Section 4 as follows:

Consider a dataset X^={xˉ1,xˉ2,⋯ ,xˉn}\widehat{\mathcal{X}}=\{\bar{x}_{1},\bar{x}_{2},\cdots,\bar{x}_{n}\} containing nn data points i.i.d. sampled from PX‾\mathcal{P}_{\overline{\mathcal{X}}}. Let P^X\hat{\mathcal{P}}_{\mathcal{X}} be the uniform distribution over X^\widehat{\mathcal{X}}. Let P^xˉ,xˉ′\hat{P}_{\bar{x},\bar{x}^{\prime}} be the uniform distribution over data pairs (xˉi,xˉj)(\bar{x}_{i},\bar{x}_{j}) where i≠ji\neq j. We define the empirical spectral contrastive loss of a feature extractor ff as

The following claim shows that L^n(f)\widehat{\mathcal{L}}_{n}({f}) is an unbiased estimator of population spectral contrastive loss.

L^n(f)\widehat{\mathcal{L}}_{n}({f}) is an unbiased estimator of L(f)\mathcal{L}({f}), i.e.,

To make use of the Radmacher complexity theory, we need to write the empirical loss as the sum of i.i.d. terms, which is achieved by the following sub-sampling scheme:

Given dataset X^\widehat{\mathcal{X}}, we sample a subset of tuples as follows: first sample a permutation π:[n]→[n]\pi:[n]\rightarrow[n], then we sample tuples S={(zi,zi+,zi′)}i=1n/2S=\{(z_{i},z_{i}^{+},z_{i}^{\prime})\}_{i=1}^{n/2} as follows:

It is easy to see that L^S(f)\widehat{\mathcal{L}}_{S}({f}) is an unbiased estimator of L^n(f)\widehat{\mathcal{L}}_{n}({f}):

For given X^\widehat{\mathcal{X}}, if we sample SS as above, we have:

This is obvious by the definition of L^S(f)\widehat{\mathcal{L}}_{S}({f}) and L^n(f)\widehat{\mathcal{L}}_{n}({f}). ∎

The following lemma reveals the relationship between the Rademacher complexity of feature extractors and the Rademacher complexity of the loss defined on tuples:

where x1,x2,⋯ ,xmx_{1},x_{2},\cdots,x_{m} are in X\mathcal{X}, and σ\sigma is a uniform random vector in {−1,1}n\{-1,1\}^{n}. Then, the empirical Rademacher complexity on any nn tuples {(zi,zi+,zi′)}i=1n\{(z_{i},z_{i}^{+},z_{i}^{\prime})\}_{i=1}^{n} can be bounded by

here the second inequality is by Talagrand’s lemma. Notice that for any z1,z2⋯znz_{1},z_{2}\cdots z_{n} and z1′,z2′,⋯ ,zn′z_{1}^{\prime},z_{2}^{\prime},\cdots,z_{n}^{\prime} in X\mathcal{X} and any i∈[k]i\in[k] we have

where the first inequaltiy is by Talagrand’s lemma. Combine these two equations and we get:

This means with probability at least 1−δ/21-\delta/2 over random X^\widehat{\mathcal{X}}, we have: with probability at least 1−δ/21-\delta/2 over random tuples SS conditioned on X^\widehat{\mathcal{X}}, Equation (44) holds. Since both L(f)\mathcal{L}({f}) and L^npre(f)\widehat{\mathcal{L}}_{{n_{\rm{pre}}}}({f}) take value in range [−2kκ2,2kκ2+k2κ4][-2k{\kappa}^{2},2k{\kappa}^{2}+k^{2}{\kappa}^{4}], we have: with probability at least 1−δ/21-{\delta}/{2} over random X^\widehat{\mathcal{X}}, we have for any f∈Ff\in\mathcal{F},

Since negating the functions in a function class doesn’t change its Rademacher complexity, we also have the other direction: with probability at least 1−δ/21-{\delta}/2 over random X^\widehat{\mathcal{X}}, we have for any f∈Ff\in\mathcal{F},

Combine them together we get the excess risk bound: with probability at least 1−δ1-\delta, we have

where f^\hat{f} is minimizer of L^npre(f)\widehat{\mathcal{L}}_{{n_{\rm{pre}}}}({f}) in F\mathcal{F} and fF∗f^{*}_{\mathcal{F}} is minimizer of L(f)\mathcal{L}({f}) in F\mathcal{F}. Set c1=64k2κ2+64kκc_{1}=64k^{2}{\kappa}^{2}+64k{\kappa} and c2=16kκ2+4k2κ4c_{2}=16k{\kappa}^{2}+4k^{2}{\kappa}^{4} and notice that max⁡i∈[k]R^npre/2(Fi)=R^npre/2(F)\max_{i\in[k]}\widehat{\mathcal{R}}_{{n_{\rm{pre}}}/2}(\mathcal{F}_{i})=\widehat{\mathcal{R}}_{{n_{\rm{pre}}}/2}(\mathcal{F}) finishes the proof. ∎

D.2 Generalization bound for spectral contrastive learning with deep neural networks

In this section, we examplify Theorem 4.1 with the norm-contralled Rademacher complexity bound introduced in Golowich et al. 2018, which gives the following theorem.

where σ(⋅)\sigma(\cdot) is element-wise ReLU activation, Pκ(⋅)P_{{\kappa}}(\cdot) is element-wise projection to interval [−κ,κ][-{\kappa},{\kappa}] for some κ>0{\kappa}>0, Cw,i{C_{w,i}} is the norm bound of the ii-th layer, WlW_{l} has kk rows and W1W_{1} has dd columns. Then, with probability at least 1−δ1-\delta over randomness of a dataset with size 2npre2{n_{\rm{pre}}}, we have

where f^\hat{f} is the minimizer of L^2npre(f)\widehat{\mathcal{L}}_{2{n_{\rm{pre}}}}({f}) in F\mathcal{F}, LF∗\mathcal{L}_{\mathcal{F}}^{*} is the minimal L(f)\mathcal{L}({f}) achievable by any function f∈Ff\in\mathcal{F}, Cw:=∏i=1lCw,i{C_{w}}:=\prod_{i=1}^{l}{C_{w,i}}, constants c1≲k2κ2+kκc_{1}\lesssim k^{2}{\kappa}^{2}+k{\kappa} and c2≲kκ2+k2κ4c_{2}\lesssim k{\kappa}^{2}+k^{2}{\kappa}^{4}.

Consider the following hypothesis class of real-valued neural networks:

where σ(⋅)\sigma(\cdot) is element-wise ReLU activation and Cw,i{C_{w,i}} is the norm bound of the ii-th layer defined in the theorem, WlW_{l} has kk rows and W^1\widehat{W}_{1} is a vector. By Theorem 1 of Golowich et al. 2018, we have

Let the projection version of this hyposis class be:

where Pκ(⋅)P_{{\kappa}}(\cdot) projects a real number into interval [−Cw,Cw][-{C_{w}},{C_{w}}]. Notice that Pκ(⋅)P_{{\kappa}}(\cdot) is 11-Lipschitz, by Telegrand’s lemma we have

and absorbing the constants into c1c_{1} finishes the proof. ∎

D.3 Proof of Theorem 4.2

In this section we give the proof of Theorem 4.2. We will first prove the following theorem that characterize the error propagation from pre-training to the downstream task.

Assume representation dimension k≥4r+2k\geq 4r+2, Assumption 3.6 holds for α>0\alpha>0 and Assumption 3.7 holds. Recall γi\gamma_{i} be the ii-th largest eigenvalue of the normalized adjacency matrix. Then, for any ϵ>0\epsilon>0 and f^emp∈F{\hat{f}_{\textup{emp}}}\in\mathcal{F} such that L(f^emp)<L(fpop∗)+ϵ\mathcal{L}({{\hat{f}_{\textup{emp}}}})<\mathcal{L}({{f^{*}_{\textup{pop}}}})+\epsilon, we have:

We first introduce the following definitions of ϵ\epsilon-optimal minimizers of matrix approximation loss and population spectral contrastive loss:

We say a function f^mf\hat{f}_{\textup{mf}} is ϵ\epsilon-optimal minimizer of matrix approximation loss Lmf\mathcal{L}_{\textup{mf}} if

where F^mf\widehat{F}_{\textup{mf}} is f^mf\hat{f}_{\textup{mf}} written in the matrix form. We say a function f^\hat{f} is ϵ\epsilon-optimal minimizer of spectral contrastive loss L\mathcal{L} if

We introduce the following generalized version of Theorem B.3, which captures the main effects of error in the representation.

where ϕy^\phi^{\hat{y}} and Δ(y,y^)\Delta(y,\hat{y}) are defined in Equations 18 and 19 respectively.

The proof of Theorem D.9 is deferred to Section D.4.

Now we are ready to prove Theorem 4.2 using Theorem D.9.

Let S1,S2,⋯ ,SrS_{1},S_{2},\cdots,S_{r} be the partition of X\mathcal{X} induced by the classifier gg in Assumption 3.6. Define function y^:X→[r]\hat{y}:\mathcal{X}\rightarrow[r] as follows: for an augmented datapoint x∈Xx\in\mathcal{X}, we use function y^(x)\hat{y}(x) to represent the index of set that xx is in, i.e., x∈Sy^(x)x\in S_{\hat{y}(x)}. Then by Lemma B.5 we have ϕy^≤2α\phi^{\hat{y}}\leq 2\alpha and Δ(y,y^)≤α\Delta(y,\hat{y})\leq\alpha. In Lemma B.4 let (1+ζ)t=⌊34k⌋+1(1+\zeta)t=\lfloor\frac{3}{4}k\rfloor+1 and t=⌊k2⌋t=\lfloor\frac{k}{2}\rfloor, then there is ζ≥0.5\zeta\geq 0.5, so we have: there exists a partition S1,⋯ ,S⌊k2⌋⊂XS_{1},\cdots,S_{\lfloor\frac{k}{2}\rfloor}\subset\mathcal{X} such that ϕG(Si)≲λ⌊34k⌋+1log⁡(k)\phi_{G}(S_{i})\lesssim\sqrt{\lambda_{\lfloor\frac{3}{4}k\rfloor+1}\log{(k)}} for ∀i∈[⌊k2⌋]\forall i\in[\lfloor\frac{k}{2}\rfloor]. By Definition 3.4, we have ρ⌊k2⌋≲λ⌊34k⌋+1log⁡(k)\rho_{\lfloor\frac{k}{2}\rfloor}\lesssim\sqrt{\lambda_{\lfloor\frac{3}{4}k\rfloor+1}\log{(k)}}, which leads to 1λ⌊34k⌋+1≲log(k)ρ⌊k2⌋2\frac{1}{\lambda_{\lfloor\frac{3}{4}k\rfloor+1}}\lesssim\frac{log(k)}{\rho_{\lfloor\frac{k}{2}\rfloor}^{2}}. So we have

Notice that by the definition of ensembled linear probe predictor, gˉf^,B^(xˉ)≠y(xˉ)\bar{g}_{\hat{f},\widehat{{B}}}(\bar{x})\neq y(\bar{x}) happens only if more than half of the augmentations of xˉ\bar{x} predicts differently from y(xˉ)y(\bar{x}), so we have Pr⁡xˉ∼PX‾(gˉf^,B^≠y(xˉ))≤2Pr⁡xˉ∼PX‾,x∼A(⋅∣xˉ)(gf^,B^(x)≠y(xˉ))\Pr_{\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}}}\left(\bar{g}_{\hat{f},\widehat{{B}}}\neq y(\bar{x})\right)\leq 2\Pr_{\bar{x}\sim\mathcal{P}_{\overline{\mathcal{X}}},{x}\sim\mathcal{A}(\cdot|\bar{x})}\left(g_{\hat{f},\widehat{{B}}}({x})\neq y(\bar{x})\right) which finishes the proof. ∎

Theorem 4.2 is a direct corollary of Theorem 4.1 and Theorem D.7. ∎

D.4 Proof of Theorem D.9

In this section, we give the proof for Theorem D.9.

The proof follows the proof of Lemma B.8. ∎

We will use the following two lemmas about ϵ\epsilon-optimal minimizer of Lmf\mathcal{L}_{\textup{mf}}:

Furthermore, the norm of FF is bounded by

Since columns of A‾−ΠfA‾\overline{A}-\Pi_{f}\overline{A} and columns of ΠfA‾−FF⊤\Pi_{f}\overline{A}-FF^{\top} are in orthogonal subspaces, we have

On one hand, since ΠfA‾\Pi_{f}\overline{A} is a rank-kk matrix, we know that ∥A‾−ΠfA‾∥F2≥min⁡FLmf(F)\left\lVert\overline{A}-\Pi_{f}\overline{A}\right\rVert_{F}^{2}\geq\min_{F}\mathcal{L}_{\textup{mf}}({F}). On the other hand, by the definition of ϵ\epsilon-optimal minimizer, we have ∥A‾−FF⊤∥F2≤min⁡FLmf(F)+ϵ\left\lVert\overline{A}-FF^{\top}\right\rVert_{F}^{2}\leq\min_{F}\mathcal{L}_{\textup{mf}}({F})+\epsilon. Thus, we have

Since A‾=∑i=1N(1−λi)vivi⊤\overline{A}=\sum_{i=1}^{N}(1-\lambda_{i})v_{i}v_{i}^{\top}, we have vi=11−λiA‾viv_{i}=\frac{1}{1-\lambda_{i}}\overline{A}{v}_{i}. Thus,

Let b=11−λiF⊤vib=\frac{1}{1-\lambda_{i}}F^{\top}v_{i}, we have

To bound the norm of FF, we first notice that

where the inequality uses that fact that A‾2\overline{A}^{2} has operator norm at most 11. Combine this result with ∥ΠfA‾−FF⊤∥F2≤ϵ\left\lVert\Pi_{f}\overline{A}-FF^{\top}\right\rVert_{F}^{2}\leq\epsilon we have

We first give a lower bound of Lmf(F)\mathcal{L}_{\textup{mf}}({F}) as follows:

where the first equality is by definition of Lmf(F)\mathcal{L}_{\textup{mf}}({F}), the second equality is by writing the Frobenius norm square as the sum of column norm square, the inequality is because A^j\widehat{A}_{j} must be in the span of z1,⋯ ,zkz_{1},\cdots,z_{k} while ΠfA‾j\Pi_{f}\overline{A}_{j} is the vector in this span that is closest to A‾j\overline{A}_{j}, the third equality is writing the projection function in the matrix form, the fourth equality is because z1,⋯zdz_{1},\cdots z_{d} are an orthonormal basis, the fifth equality is rewriting to Frobenius norm, and the last equality is by definition of Πf⊥\Pi_{f}^{\perp}.

We define variable Sj≜∑t=1j∑l=k+1d⟨vt,zl⟩2S_{j}\triangleq\sum_{t=1}^{j}\sum_{l=k+1}^{d}\langle{v}_{t},z_{l}\rangle^{2} for any j∈[N]j\in[N]. Also denote λd+1=1\lambda_{d+1}=1. We have the following equality:

Notice that Sj≥0S_{j}\geq 0 and also when i≤j≤ki\leq j\leq k, we have Sj≥∥Πf⊥vi∥22S_{j}\geq\left\lVert\Pi_{f}^{\perp}{v}_{i}\right\rVert_{2}^{2}, we have

where we replace every SjS_{j} with 00 when j<kj<k, replace SjS_{j} with ∥Πf⊥vi∥22\left\lVert\Pi_{f}^{\perp}{v}_{i}\right\rVert_{2}^{2} when i≤j≤ki\leq j\leq k, and keep SjS_{j} when j≥k+1j\geq k+1. Now notice that

there must be Sj≥j−kS_{j}\geq j-k when j≥k+1j\geq k+1. So we have

where the last equality is by Eckart–Young–Mirsky Theorem. So we know

The following lemma generalizes Lemma B.6.

Furethermore, the norm of bb is upper bounded by

Let k′k^{\prime} be the choice that minimizes the right hand side. We use pv(u)p_{v}(u) to denote the projection of uu onto the span of v1,⋯ ,vk′{v}_{1},\cdots,{v}_{k^{\prime}}. We denote the coefficients as pv(u)=∑i=1k′ρivip_{v}(u)=\sum_{i=1}^{k^{\prime}}\rho_{i}{v}_{i}. For every i∈[k′]i\in[k^{\prime}], let bib_{i} be the vector in Lemma D.11. Define vector b=∑i=1k′ρibib=\sum_{i=1}^{k^{\prime}}\rho_{i}b_{i}.

We use pv,f(u)p_{{v},f}(u) to denote the projection of pv(u)p_{v}(u) onto the span of f1,⋯ ,fkf_{1},\cdots,f_{k}. Then we know that

where the first inequality if by Cauchy–Schwarz inequality and the second inequality if by Lemma D.12.

where the first inequality is by Cauchy-Schwarz inequality, and the second inequality is by Lemma D.11. Plugging Equation (61), Equation (62), and Equation (D.4) into Equation (60) finishes the proof.

To bound the norm of bb, we use Lemma D.11 and have

Now we prove Theorem D.9 using the above lemmas.

Let matrices U=[u1,⋯ ,ur]U=[u_{1},\cdots,u_{r}] and B^⊤=[b1,⋯ ,br]\widehat{B}^{\top}=[b_{1},\cdots,b_{r}]. We sum the above equation over all i∈[r]i\in[r] and get

where the first equality is by Claim B.7. On the other hand, we have

Plugging Equation (66) and Equation (67) into Equation (65) gives us

Notice that by definition of u(x)u(x), we know that prediction gf^,B^(x)≠y^(x)g_{\hat{f},\widehat{B}}(x)\neq\hat{y}(x) only happens if ∥u(x)−B^f^(x)∥22≥wx2\left\lVert u(x)-\widehat{B}\hat{f}(x)\right\rVert_{2}^{2}\geq\frac{w_{x}}{2}. Hence we have

Now we are ready to bound the error rate on X\mathcal{X}:

Here for the equality we are using the fact that Pr⁡(x)=wx\Pr(x)=w_{x}. We finish the proof by noticing that by the definition of Δ(y,y^)\Delta(y,\hat{y}):

The norm of B^\widehat{B} can be bounded using Lemma D.13 as:

Appendix E Proofs for Section 4.2

In this section we give the proof of Theorem 4.3.

Let f^emp{\hat{f}_{\textup{emp}}} be the minimizer of the empirical spectral contrastive loss. Let ϵ=L(f^emp)−L(fpop∗)\epsilon=\mathcal{L}({{\hat{f}_{\textup{emp}}}})-\mathcal{L}({{f^{*}_{\textup{pop}}}}). We abuse notation and use yiy_{i} to denote y(xˉi)y(\bar{x}_{i}), and let zi=f^emp(xi)z_{i}={\hat{f}_{\textup{emp}}}(x_{i}). We first study the average empirical Rademacher complexity of the capped quadratic loss on a dataset {(zi,yi)}i=1ndown\{(z_{i},y_{i})\}_{i=1}^{n_{\rm{down}}}, where (zi,yi)(z_{i},y_{i}) is sampled as in Section 4.2:

By Theorem D.9 and follow the proof of Theorem D.7, we know that there exists a linear probe B^∗\widehat{B}^{*} with norm bound ∥B^∗∥F≤Ck\left\lVert\widehat{B}^{*}\right\rVert_{F}\leq C_{k} such that

The result on gˉf^emp,B^\bar{g}_{{\hat{f}_{\textup{emp}}},\widehat{{B}}} naturally follows by the definition of gˉ\bar{g}. When ϵ>1\epsilon>1 clearly the bound is also true since LHS is always smaller than 11, so we know that the above bound is true for any ϵ\epsilon. Plug in the bound for ϵ\epsilon from Theorem 4.1 finishes the proof. ∎

Appendix F Formal statements for population with infinite supports

The distribution ww satisfies the following conditions:

(i) For any u∈Xu\in\mathcal{X}, the marginal distribution is well-defined and bouned w(u)=∫w(u,z)dz<∞w(u)=\int w(u,z)dz<\infty.

(ii) There exists B>0B>0 such that for every u,v∈Xu,v\in\mathcal{X}, the conditional probability with respect to one variable is upper bounded by the marginal probability of the other variable w(u,v)w(u)≤B⋅w(v)\frac{w(u,v)}{w(u)}\leq B\cdot w(v).

We note that our bound does not depend on value of BB—we only the existence of BB for a qualitative purpose. When the regularity conditions above hold, we will show that there exists an eigenfunction of the infinite adjacency graph is an analog to the eigenvectors of Laplacian that we introduced in Section B.

The following theorem shows the existence of eigenfunctions of the Laplacian operator.

Define kernel function k(u,v)≜w(u,v)w(u)w(v)k(u,v)\triangleq\frac{w(u,v)}{\sqrt{w(u)w(v)}}, we have

On the one hand, since w(u,v)≥0w(u,v)\geq 0 and ⟨fi,fi⟩=1\langle f_{i},f_{i}\rangle=1, we have λi≤1\lambda_{i}\leq 1. On the other hand, notice that by Cauchy-Schwart inequality,

so λi≥0\lambda_{i}\geq 0, which finishes the proof. ∎