O N M UTUAL I NFORMATION M AXIMIZATION FOR R EPRESENTATION L EARNING
Google Research, Brain Team
A BSTRACT
Many recent methods for unsupervised or self-supervised representation learning train feature extractors by maximizing an estimate of the mutual information (MI) between different views of the data.
This comes with several immediate problems:
For example, MI is notoriously hard to estimate, and using it as an objective for representation learning may lead to highly entangled representations due to its invariance under arbitrary invertible transformations.
Nevertheless, these methods have been repeatedly shown to excel in practice.
In this paper we argue, and provide empirical evidence, that the success of these methods cannot be attributed to the properties of MI alone, and that they strongly depend on the inductive bias in both the choice of feature extractor architectures and the parametrization of the employed MI estimators.
Finally, we establish a connection to deep metric learning and argue that this interpretation may be a plausible explanation for the success of the recently introduced methods.
I NTRODUCTION
Unsupervised representation learning is a fundamental problem in machine learning.
Intuitively, one aims to learn a function g which maps the data into some, usually lower-dimensional, space where one can solve some (generally a priori unknown) target supervised tasks more efﬁciently, i.e. with fewer labels.
In contrast to supervised and semi-supervised learning, the learner has access only to unlabeled data .
Even though the task seems ill-posed as there is no natural objective one should optimize, by leveraging domain knowledge this approach can be successfully applied to a variety of problem areas, including image (Kolesnikov et al., 2019; van den Oord et al., 2018;
Hénaff et al., 2019; Tian et al., 2019; Hjelm et al., 2019; Bachman et al., 2019) and video classiﬁcation (Wang and
Gupta, 2015; Sun et al., 2019), and natural language understanding (van den Oord et al., 2018; Peters et al., 2018; Devlin et al., 2019).
Recently, there has been a revival of approaches inspired by the InfoMax principle (Linsker, 1988):
Choose a representation g ( x ) maximizing the mutual information (MI) between the input and its representation, possibly subject to some structural constraints.
MI measures the amount of information obtained about a random variable X by observing some other random variable Y 1 Formally, the MI between X and Y , with joint density p ( x, y ) and marginal densities p ( x ) and p ( y ) , is deﬁned as the
Kullback–Leibler (KL) divergence between the joint and the product of the marginals
[Equation]
The fundamental properties of MI are well understood and have been extensively studied (see e.g. Kraskov et al.
Firstly, MI is invariant under reparametrization of the variables — namely, if X (cid:48)
=
f 1 ( X ) and Y (cid:48) =
f 2 ( Y ) are homeomorphisms (i.e. smooth invertible maps), then
I ( X ; Y ) =
I ( X (cid:48) ; Y (cid:48) ) .
Secondly, estimating MI in high-dimensional spaces is a notoriously difﬁcult task, and in practice one often maximizes a tractable lower bound on this quantity (Poole et al., 2019).
Nonetheless, any distribution-free high-conﬁdence lower bound on entropy requires a sample size exponential in the size of the bound (McAllester and Statos, 2018).
Despite these fundamental challenges, several recent works have demonstrated promising empirical results in representation learning using MI maximization (van den Oord et al., 2018; Hénaff et al., 2019; Tian et al., 2019; Hjelm et al., 2019;
Bachman et al., 2019; Sun et al., 2019).
In this work we argue, and provide empirical evidence, that the success of these methods cannot be attributed to the properties of MI alone.
In fact, we show that maximizing tighter bounds on MI can result in worse representations.
In addition, we establish a connection to deep metric learning and argue that this interpretation may be a plausible explanation of the success of the recently introduced methods.
B ACKGROUND AND R ELATED W ORK
Recent progress and the InfoMax principle While promising results in other domains have been presented in the literature, we will focus on unsupervised image representation learning techniques that have achieved state-of-the-art performance on image classiﬁcation tasks (Hénaff et al., 2019;
Tian et al., 2019; Bachman et al., 2019).
The usual problem setup dates back at least to Becker and
Hinton (1992) and can conceptually be described as follows:
For a given image X , let X (1) and X (2) be different, possibly overlapping views of X , for instance the top and bottom halves of the image.
These are encoded using encoders g 1 and g 2 respectively, and the MI between the two representations g 1 ( X (1) ) and g 2 ( X (2) ) is maximized,
[Equation]
where I EST ( X ; Y ) is a sample-based estimator of the true MI
I ( X ; Y ) and the function classes
G 1 and G 2 can be used to specify structural constraints on the encoders.
While not explicitly reﬂected in (2), note that g 1 and g 2 can often share parameters.
Furthermore, it can be shown that
I ( g 1 ( X (1) ); g 2 ( X (2) )) ≤ I ( X ; g 1 ( X (1) ) , g 2 ( X (2) )) , 3 hence the objective in (2) can be seen as a lower bound on the InfoMax objective max g ∈G I
( X ; g ( X ))
(Linsker, 1988).
Practical advantages of multi-view formulations There are two main advantages in using (2) rather than the original InfoMax objective.
First, the MI has to be estimated only between the learned representations of the two views, which typically lie on a much lower-dimensional space than the one where the original data X lives.
Second, it gives us plenty of modeling ﬂexibility, as the two views can be chosen to capture completely different aspects and modalities of the data, for example:
In the basic form of DeepInfoMax (Hjelm et al., 2019) g 1 extracts global features from the entire image
X (1) and g 2 local features from image patches X (2) , where g 1 and g 2 correspond to activations in different layers of the same convolutional network.
Bachman et al.
(2019) build on this and compute the two views from different augmentations of the same image.
Contrastive multiview coding (CMC) (Tian et al., 2019) generalizes the objective in (2) to consider multiple views X ( i ) , where each X ( i ) corresponds to a different image modality (e g., different color channels, or the image and its segmentation mask).
Contrastive predictive coding (CPC) (van den Oord et al., 2018; Hénaff et al., 2019) incorporates a sequential component of the data.
Concretely, one extracts a sequence of patches from an image in some ﬁxed order, maps each patch using an encoder, aggregates the resulting features of the ﬁrst t patches into a context vector, and maximizes the MI between the context and features extracted from the patch at position t
+ k .
In (2), X (1) would thus correspond to the ﬁrst t patches and X (2) to the patch at location t + k .
Other approaches, such as those presented by Sermanet et al.
(2018), Hu et al.
(2017), and Ji et al.
(2019), can be similarly subsumed under the same objective.
Lower bounds on MI As evident from (2), another critical choice is the MI estimator I EST .
Given the fundamental limitations of MI estimation (McAllester and Statos, 2018), recent work has focused on deriving lower bounds on MI (Barber and Agakov, 2003; Belghazi et al., 2018; Poole et al.,
Intuitively, these bounds are based on the following idea: If a classiﬁer can accurately distinguish between samples drawn from the joint p ( x, y ) and those drawn from the product of marginals p ( x ) p ( y ) , then X and Y have a high MI.
We will focus on two such estimators, which are most commonly used in the representation learning literature.
The ﬁrst of them, termed InfoNCE (van den Oord et al., 2018), is deﬁned as
[Equation]
where the expectation is over K independent samples { ( x i , y i ) }
Ki =1 from the joint distribution p ( x, y )
(Poole et al., 2019).
In practice we estimate (3) using Monte Carlo estimation by averaging over multiple batches of samples.
Intuitively, the critic function f tries to predict for each x i which of the K samples y 1 , . . .
y k
it was jointly drawn with, by assigning high values to the jointly drawn pair, and low values to all other pairs.
The second estimator is based on the variational form of the KL divergence due to Nguyen, Wainwright, and Jordan (NWJ) (Nguyen et al., 2010) and takes the form
[Equation]
For detailed derivations we refer the reader to (Ruderman et al., 2012; Poole et al., 2019).
Note that these bounds hold for any critic f and when used in (2) one in practice jointly maximizes over g 1 , g 2 and f .
Furthermore, it can be shown that (3) is maximized by f ∗ ( x, y )
= log p ( y | x ) and (4) by f ∗ ( x, y )
=
1 + log p ( y | x ) (Poole et al., 2019).
Common choices for f include bilinear critics f ( x, y )
=
x (cid:62) Wy (van den Oord et al., 2018; Hénaff et al., 2019; Tian et al., 2019), separable critics f ( x, y ) =
φ 1 ( x ) (cid:62) φ 2 ( y ) (Bachman et al., 2019), and concatenated critics f ( x, y )
=
φ ([ x, y ])
(Hjelm et al., 2019) (here φ, φ 1 , φ 2 are typically shallow multi-layer perceptrons (MLPs)).
When applying these estimators to solve (2), the line between the critic and the encoders g 1 , g 2 can be blurry.
For example, one can train with an inner product critic f
( x, y )
=
x (cid:62) y , but extract features from an intermediate layer of g 1 , g 2 , in which case the top layers of g 1 , g 2 form a separable critic.
Nevertheless, this boundary is crucial for the interplay between MI estimation and the interpretation of the learned representations.
B IASES IN APPROXIMATE INFORMATION MAXIMIZATION
It is folklore knowledge that maximizing MI does not necessarily lead to useful representations.
Already Linsker (1988) talks in his seminal work about constraints, while a manifestation of the problem in clustering approaches using MI criteria has been brought up by Bridle et al.
and subsequently addressed using regularization by Krause et al.
To what can we then attribute the recent success of methods building on the principles of MI maximization?
We will argue that their connection to the InfoMax principle might be very loose.
Namely, we will show that they behave counter-intuitively if one equates them with MI maximization, and that the performance of these methods depends strongly on the bias that is encoded not only in the encoders, but also on the actual form of the used estimators.
We ﬁrst consider encoders which are bijective by design.
Even though the true MI is maximized for any choice of model parameters, the representation quality (measured by downstream linear classiﬁcation accuracy) improves during training.
Furthermore, there exist invertible encoders for which the representation quality is worse than using raw pixels, despite also maximizing MI.
We next consider encoders that can model both invertible and non-invertible functions.
When the encoder can be non-invertible, but is initialized to be invertible, I EST still biases the encoders to be very ill-conditioned and hard to invert.
For I NCE and I NWJ , higher-capacity critics admit tighter bounds on MI.
We demonstrate that simple critics yielding loose bounds can lead to better representations than high-capacity critics.
Finally, we optimize the estimators to the same MI lower-bound value with different encoder architectures and show that the representation quality can be impacted more by the choice of the architecture, than the estimator.
As a consequence, we argue that the success of these methods and the way they are instantiated in practice is only loosely connected to MI.
Then, in Section 4 we provide an alternative explanation for the success of recent methods through a connection to classic triplet losses from metric learning. [Figure] [Figure] I E S T
[Figure] [Figure] [Figure] [Figure]
[Figure]
[Figure]
[Figure]
cc
[Figure]
r a c y
I NWJ
I
[Figure]
[Figure]
[Figure]
[Figure]
[Figure]
[Figure] [Figure] [Figure] y
[Figure]
Setup Our goal is to provide a minimal set of easily reproducible empirical experiments to understand the role of MI estimators, critic and encoder architectures when learning representations via the objective (2).
To this end, we consider a simple setup of learning a representation of the top half of
MNIST handwritten digit images (we present results for the experiments from Sections 3.2 and 3.
on CIFAR10 in Appendix G; the conclusions are analogous).
This setup has been used in the context of deep canonical correlation analysis (Andrew et al., 2013), where the target is to maximize the correlation between the representations.
Following the widely adopted downstream linear evaluation protocol (Kolesnikov et al., 2019; van den Oord et al., 2018;
Hénaff et al., 2019; Tian et al., 2019;
Hjelm et al., 2019; Bachman et al., 2019), we train a linear classiﬁer 4 for digit classiﬁcation on the learned representation using all available training labels (other evaluation protocols are discussed in Section 5).
To learn the representation we instantiate (2) and split each input MNIST image x ∈ [0 , 1] 784 into two parts, the top part of the image x top ∈ [0 , 1] 392 corresponding to X (1) , and the bottom part, x bottom ∈ [0 , 1] 392 , corresponding to X (2) , respectively.
We train g 1 , g 2 , and f using the Adam optimizer (Kingma and Ba, 2015), and use g 1 ( x top ) as the representation for the linear evaluation.
Unless stated otherwise, we use a bilinear critic f
( x, y ) =
x (cid:62)
Wy (we investigate its effect in a separate ablation study), set the batch size to 128 and the learning rate to 10 − 4 .
Throughout, I EST values and downstream classiﬁcation accuracies are averaged over 20 runs and reported on the testing set (we did not observe large gaps between the training and testing values of
I EST ).
As a common baseline, we rely on a linear classiﬁer in pixel space on x top , which obtains a testing accuracy of about 85% .
For comparison, a simple MLP or ConvNet architecture achieves about 94% (see Section 3.3 for details).
3. L ARGE MI IS NOT PREDICTIVE OF DOWNSTREAM PERFORMANCE
We start by investigating the behavior of I NCE and I NWJ when g 1 and g 2 are parameterized to be always invertible.
Hence, for any choice of the encoder parameters, the MI is constant, i.e.
I ( g 1 ( X (1) ); g 2 ( X (2) ))
=
I ( X (1) ; X (2) ) for all g 1 , g 2 .
This means that if we could exactly compute the MI, any parameter choice would be a global maximizer and thus the gradients vanish everywhere.
However, as we will empirically show, the estimators we consider are biased and prefer those settings which yield representations useful for the downstream classiﬁcation task.
Maximized MI and improved downstream performance We model g 1 and g 2 using the invertible RealNVP architecture (Dinh et al., 2016).
We use a total of 30 coupling layers, and each of them computes the shift using a separate MLP with two ReLU hidden layers, each with 512 units. [Figure]
I {+E S T I NWJ I NCE (a)    20 Training steps (in thousands) 0.83 0. A cc u r a c y I NWJ I NCE (b)    20 Training steps (in thousands) 
+}
J a c o b i a n , l o g ( σ 1 / σ 392 ) Minimum 20th perc. 40th perc. 60th perc.
80th perc.
[Figure]
Figure 1 shows the testing value of I EST and the testing accuracy on the classiﬁcation task. Despite the fact that MI is maximized by any instantiation of g 1 and g 2 , I EST and downstream accuracy increase during training, implying that the estimators provide gradient feedback leading to a representation useful for linear classiﬁcation.
This conﬁrms our hypothesis that the estimator biases the encoders towards solutions suitable to solve the downstream linear classiﬁcation task
The previous experiment demonstrated that among many invertible encoders, all of which are globally optimal MI maximizers, some give rise to improved linear classiﬁcation performance over raw pixels, and maximizing I NCE and I NWJ yields such encoders.
Next we demonstrate that for the same invertible encoder architecture there are model parameters for which linear classiﬁcation performance is signiﬁcantly worse than using raw pixels, despite also being globally optimal MI maximizers.
Maximized MI and worsened downstream performance
The goal is to learn a (bijective) representation maximizing MI such that the optimal linear classiﬁer performs poorly; we achieve this by jointly training a representation and classiﬁer in an adversarial fashion (a separate classiﬁer is trained for the evaluation), without using a MI estimator.
Intuitively, we will train the encoder to make the classiﬁcation task for the linear layer as hard as possible.
The experimental details are presented in Appendix B. Figure 1c shows the result of one such training run, displaying the loss of a separately trained classiﬁer on top of the frozen representation.
At the beginning of training the network is initialized to be close to the identity mapping, and as such achieves the baseline classiﬁcation accuracy corresponding to raw pixels.
All points beyond this correspond to invertible feature maps with worse classiﬁcation performance, despite still achieving globally maximal MI.
Alternatively, the following thought experiment would yield the same conclusion: Using a lossless compression algorithm (e.g. PNG) for g 1 and g 2 also satisﬁes I ( g 1 ( X (1) ); g 2 ( X (2) ))
=
I ( X (1) ; X (2) ) .
Yet, performing linear classiﬁcation on the raw compressed bit stream g 1 ( X (1) ) will likely lead to worse performance than the baseline in pixel space.
The information content alone is not sufﬁcient to guarantee a useful geometry in the representation space.
We next investigate the behavior of the model if we use a network architecture that can model both invertible and non-invertible functions.
We would like to understand whether I EST prefers the network to remain bijective, thus maximizing the true MI, or to ignore part of the input signal, which can be beneﬁcial for representation learning.
Bias towards hard-to-invert encoders We use an MLP architecture with 4 hidden layers of the same dimension as the input, and with a skip connection added to each layer (hence by setting all weights to 0 the network becomes the identity function).
As quantifying invertibility is hard, we analyze the condition number, i.e. the ratio between the largest and the smallest singular value, of the Jacobian of g 1 :
By the implicit function theorem, the function is invertible if the Jacobian is non-singular.
However, the data itself might lie on a low-dimensional manifold, so that having a singular Jacobian is not necessarily indicative of losing invertibility on the support of the data [Figure] , while distribution.
To ensure the support of the data distribution covers the complete input space, we corrupt
X (1) and X (2) in a coupled way by adding to each the same 392-dimensional random vector, whose coordinates are sampled (independently of X (1) , X (2) ) from a normal with standard deviation 0 .(the standard deviation of the pixels themselves is 0.3).
Hence, non-invertible encoders g 1 , g 2 do not maximize I ( g 1 ( X (1) ); g 2 ( X (2) )) . 8 As a reference point, the linear classiﬁcation accuracy from pixels drops to about 84% due to the added noise.
In Figure 2 we can see that the I EST value and the downstream accuracy both increase during training, as before.
Moreover, even though g 1 is initialized very close to the identity function (which maximizes the true MI), the condition number of its Jacobian evaluated at inputs randomly sampled from the data-distribution steadily deteriorates over time, suggesting that in practice (i.e. numerically) inverting the model becomes increasingly hard.
It therefore seems that the bounds we consider favor hard-to-invert encoders, which heavily attenuate part of the noise (as the support of the noise is the entire input space), over well conditioned encoders (such as the identity function at initialization), which preserve the noise and hence the entropy of the data well.
3. H IGHER CAPACITY CRITICS CAN LEAD TO WORSE DOWNSTREAM PERFORMANCE
In the previous section we have established that MI and downstream performance are only loosely connected.
Clearly, maximizing MI is not sufﬁcient to learn good representations and there is a non-trivial interplay between the architectures of the encoder, critic, and the underlying estimators.
In this section, we will focus on how one of these factors, namely the critic architecture, impacts the quality of the learned representation.
Recall that it determines how the estimators such as I NCE and I NWJ distinguish between samples from the joint distribution p ( x, y ) and the product of the marginals p ( x ) p ( y ) , and thereby determines the tightness on the lower bound.
A higher capacity critic should allow for a tighter lower-bound on MI (Belghazi et al., 2018).
Furthermore, in the context of representation learning where f is instantiated as a neural network, the critic provides gradient feedback to g 1 and g 2 and thereby shapes the learned representation.
Looser bounds with simpler critics can lead to better representations We compare three critic architectures, a bilinear critic, a separable critic f
( x, y ) =
φ 1 ( x ) (cid:62) φ 2 ( y ) ( φ 1 , φ 2 are MLPs with a single hidden layer with 100 units and ReLU activations, followed by a linear layer with 100 units; comprising 40 k parameters in total) and an MLP critic with a single hidden layer with 200 units and
ReLU activations, applied to the concatenated input [ x, y ] ( 40 k trainable parameters).
Further, we use identical MLP architectures for g 1 and g 2 with two hidden layers comprising 300 units each, and a third linear layer mapping to a 100 -dimensional feature space.
Figure 3 shows the downstream testing accuracy and the testing I EST value as a function of the iteration (see Appendix G for the corresponding results on CIFAR10).
It can be seen that for both lower bounds, representations trained with the MLP critic barely outperform the baseline on pixel space, whereas the same lower bounds with bilinear and separable critics clearly lead to a higher accuracy than the baseline.
While the testing I NCE value is close to the theoretically achievable maximum value for all critics, the testing I NWJ value is higher for the MLP critic than for the separable and bilinear critics, resulting in a tighter bound on the MI.
However, despite achieving the smallest
[Figure]
[Figure]
and I NWJ estimators can be greater than the true MI.
Despite being commonly justiﬁed as a lower bound on MI, I NCE is often used in the non- i.i.d.
setting in practice.
I NWJ testing value, the simple bilinear critic leads to a better downstream performance than the higher-capacity separable and MLP critics.
A related phenomenon was observed in the context of variational autoencoders (VAEs) (Kingma and
Welling, 2014), where one maximizes a lower bound on the data likelihood: Looser bounds often yield better inference models, i.e. latent representations (Rainforth et al., 2018).
3. E NCODER ARCHITECTURE CAN BE MORE IMPORTANT THAN THE SPECIFIC ESTIMATOR
We will now show that the encoder architecture is a critical design choice and we will investigate its effect on the learned representation.
We consider the same MLP architecture ( 238 k parameters) as in Section 3.2, as well as a ConvNet architecture comprising two convolution layers (with a 5 ×kernel, stride of 2 , ReLU activations, and 64 and 128 channels, respectively; 220 k parameters), followed by spatial average pooling and a fully connected layer.
Before the average pooling operation we apply layer normalization (Ba et al., 2016) which greatly reduces the variance of I NWJ .
9 To ensure that both network architectures achieve the same lower bound I EST on the MI, we minimize
L t ( g 1 , g 2 ) =
| I EST ( g 1 ( X (1) ); g 1 ( X (2) ))
− t | instead of solving (2), for two different values t = 2 , 4 .
Figure 4 shows the downstream testing accuracy as a function of the training iteration (see Appendix G for the corresponding results on CIFAR10).
It can be seen in the testing loss curves in Appendix F that for both architectures and estimators the objective value after 7 k iterations matches the target t (i.e., L t ( g 1 , g 2 ) ≈ 0 ) which implies that they achieve the same lower-bound on the MI.
Despite matching lower bounds, ConvNet encoders lead to clearly superior classiﬁcation accuracy, for both
I NCE and I NWJ .
Note that, in contrast, the MLP and ConvNet architectures trained end-to-end in supervised fashion both achieve essentially the same testing accuracy of about 94% .
In the context of VAEs, Alemi et al.
(2018) similarly observed that models achieving the same evidence lower bound value can lead to vastly different representations depending on the employed encoder architecture, and do not necessarily capture useful information about the data (Tschannen et al., 2018; Blau and Michaeli, 2019).
C ONNECTION TO DEEP METRIC LEARNING AND TRIPLET LOSSES
In the previous section we empirically demonstrated that there is a disconnect between approximate
MI maximization and representation quality.
However, many recent works have applied the I NCE estimator to obtain state-of-the-art results in practice.
We provide some insight on this conundrum by connecting I NCE to a popular triplet ( k -plet) loss known in the deep metric learning community.
The metric learning view Given sets of triplets, namely an anchor point x , a positive instance y , and a negative instance z , the goal is to learn a representation g ( x ) such that the distances (i.e., (cid:96) 2 ) between g ( x ) and g ( y ) is smaller than the distance between g ( x ) and g ( z ) , for each triplet.
In the supervised setting, the positive instances are usually sampled from the same class, while the negative instances are sampled from any other class.
A major focus in deep metric learning is how to perform (semi-)hard positive mining — we want to present non-trivial triplets to the learning algorithm which become more challenging as g improves.
Natural extensions to the unsupervised setting can be obtained by exploiting the structure present in the input data, namely spatial (e.g. patches from the same image should be closer than patches from different images) and temporal information (temporally close video frames should be encoded closer than the ones which are further away in time)
(Hoffer and Ailon, 2015).
Connection to InfoNCE The InfoNCE objective can be rewritten as follows:
[Equation]
The derivation is presented in Appendix C. In the particular case that x and y take value in the same space and f is constrained to be of the form f ( x, y )
=
φ ( x ) (cid:62) φ ( y ) , for some function φ , this coincides (up to constants and change of sign) with the expectation of the multi-class K-pair loss proposed in (Sohn, 2016, Eqn. (7)): L
[Equation]
Representation learning by maximizing I NCE using a symmetric separable critic f ( x, y )
=
φ ( x ) (cid:62) φ ( y ) and an encoder g = g 1 = g 2 shared across views is thus equivalent to metric learning based on (5).
When using different encoders for different views and asymmetric critics as employed by CPC,
DeepInfoMax, and CMC one recovers asymmetric variants of (5), see, e.g. (Yu et al., 2017; Zhang et al., 2019).
As a result, one can view (5) as learning encoders with a parameter-less inner product critic, for which the MI lower-bound is very weak in general.
There are (at least) two immediate beneﬁts of viewing recent representation learning methods based on MI estimators through the lens of metric learning.
Firstly, in the MI view, using inner product or bilinear critic functions is sub-optimal since the critic should ideally be as ﬂexible as possible in order to reduce the gap between the lower bound and the true MI.
In the metric learning view, the inner product critic corresponds to a simple metric on the embedding space.
The metric learning view seems hence in better accordance with the observations from Section 3.2 than the MI view.
Secondly, it elucidates the importance of appropriately choosing the negative samples, which is indeed a critical component in deep metric learning based on triplet losses (Norouzi et al., 2012; Schroff et al., 2015).
InfoNCE and the importance of negative sampling The negative sample mining issue also manifests itself in MI-based contrastive losses.
In fact, while InfoNCE is a lower bound on MI if the negative samples are drawn from the true marginal distribution (Poole et al., 2019), i.e.
[Equation]
we show that if the negative samples are drawn in a dependent fashion (corresponding to the ( x i , y i ) being drawn identically but not independently ), the I NCE estimator is in general neither a lower nor an upper bound on the true MI
I ( X, Y ) .
We prove this in Appendix D and present empirical evidence here.
Let ( X, Y )
=
Z + (cid:15) , where Z ∼ N (0 , Σ Z ) and (cid:15) ∼ N (0 , Σ (cid:15) ) are two-dimensional Gaussians.
We generate batches of data ( X i , Y i )
=
Z + (cid:15) i where each (cid:15) i is sampled independently for each element of the batch, but Z is sampled only once per batch.
As such, ( X i , Y i ) has the same marginal distribution for each i , but the elements of the batch are not independent .
Although we do not treat it theoretically, we also display results of the same experiment using the I NWJ estimator.
The experimental details are presented in
Appendix E. We observe in Figure 4c that when using noni.i.d.
samples both the I NCE and I NWJ values are larger than the true MI, and that when i.i.d.
samples are used, both are lower bounds on the true MI.
Hence, the connection to MI under improper negative sampling is no longer clear and might vanish completely.
Notwithstanding this fundamental problem, the negative sampling strategy is often treated as a design choice.
In Hénaff et al.
(2019), CPC is applied to images by partitioning the input image into patches.
Then, MI (estimated by InfoNCE) between representations of patches and a context summarizing several patches that are vertically above or below in the same image is minimized.
Negative samples are obtained by patches from different images as well as patches from the same image, violating the independence assumption.
Similarly, van den Oord et al.
(2018) learn representations of speech using samples from a variety of speakers.
It was found that using utterances from the same speaker as negative samples is more effective, whereas the “proper” negative samples should be drawn from an appropriate mixture of utterances from all speakers.
A common observation is that increasing the number of negative examples helps in practice (Hjelm et al., 2019; Tian et al., 2019; Bachman et al., 2019).
Indeed, Ma and Collins (2018) show that I NCE is consistent for any number of negative samples (under technical conditions), and Poole et al.
(2019) show that the signal-to-noise ratio increases with the number of negative samples.
On the other hand, (Arora et al., 2019) have demonstrated, both theoretically and empirically, that increasing the number of negative samples does not necessarily help, and can even deteriorate the performance.
The intricacies of negative sampling hence remain a key research challenge.
C ONCLUSION
Is MI maximization a good objective for learning good representations in an unsupervised fashion?
Possibly, but it is clearly not sufﬁcient.
In this work we have demonstrated that, under the common linear evaluation protocol, maximizing lower bounds on MI as done in modern incarnations of the InfoMax principle can result in bad representations.
We have revealed that the commonly used estimators have strong inductive biases and—perhaps surprisingly—looser bounds can lead to better representations.
Furthermore, we have demonstrated that the connection of recent approaches to MI maximization might vanish if negative samples are not drawn independently (as done by some approaches in the literature).
As a result, it is unclear whether the connection to MI is a sufﬁcient (or necessary) component for designing powerful unsupervised representation learning algorithms.
We propose that the success of these recent methods could be explained through the view of triplet-based metric learning and that leveraging advances in that domain might lead to further improvements.
We have several suggestions for future work, which we summarize in the following.
Alternative measures of information We believe that the question of developing new notions of information suitable for representation learning should receive more attention. While MI has appealing theoretical properties, it is clearly not sufﬁcient for this task—it is hard to estimate, invariant to bijections and can result in suboptimal representations which do not correlate with downstream performance. Therefore, a new notion of information should account for both the amount of information stored in a representation and the geometry of the induced space necessary for good performance on downstream tasks. One possible avenue is to consider extensions to MI which explicitly account for the modeling power and computational constraints of the observer, such as the recently introduced F -information Xu et al.
Alternatively, one can investigate other statistical divergences to measure the discrepancy between p ( x, y ) and p ( x ) p ( y ) . For example, using the Wasserstein distance leads to promising results in representation learning as it naturally enforces smoothness in the encoders (Ozair et al., 2019). A holistic view We believe that any theory on measuring information for representation learning built on critics should explicitly take into account the function families one uses (e.g. that of the critic and estimator). Most importantly, we would expect some natural trade-offs between the amount of information that can be stored against how hard it is to extract it in the downstream tasks as a function of the architectural choices.
While the distribution of downstream tasks is typically assumed unknown in representation learning, it might be possible to rely on weaker assumptions such as a family of invariances relevant for the downstream tasks. Moreover, it seems that in the literature (i) the critics that are used to measure the information, (ii) the encoders, and (iii) the downstream models/evaluation protocol are all mostly chosen independently of each other. Our empirical results show that the downstream performance depends on the intricate balance between these choices and we believe that one should co-design them. This holistic view is currently under-explored and due to the lack of any theory or extensive studies to guide the practitioners.
Going beyond the widely used linear evaluation protocol While it was shown that learning good representations under the linear evaluation protocol can lead to reduced sample complexity for downstream tasks (Arora et al., 2019), some recent works (Bachman et al., 2019; Tian et al., 2019) report marginal improvements in terms of the downstream performance under a non-linear regime.
Related to the previous point, it would hence be interesting to further explore the implications of the evaluation protocol, in particular its importance in the context of other design choices.
We stress that a highly-nonlinear evaluation framework may result in better downstream performance, but it defeats the purpose of learning efﬁciently transferable data representations.
Systematic investigations into design decisions that matter
On the practical side, we believe that the link to metric learning could lead to new methods, that break away from the goal of estimating MI and place more weight on the aspects that have a stronger effect on the performance such as the negative sampling strategy. An example where the metric learning perspective led to similar methods as the MI view is presented by Sermanet et al. (2018): They developed a multi-view representation learning approach for video data similar to CMC, but without drawing negative samples independently and seemingly without relying on the MI mental model to motivate their design choices.
A CKNOWLEDGMENTS
We would like to thank Alex Alemi, Ben Poole, Olivier Bachem, and Alexey Dosovitskiy for inspiring discussions and comments on the manuscript.
We are grateful for the general support and discussions from other members of Google Brain team in Zurich.
A PPENDIX A R ELATION BETWEEN (2) AND THE I NFO M AX OBJECTIVE
Proposition 1.
Let X be a random variable and deﬁne X
= g 1 ( X ) and X 2 = g 2 ( X ) be arbitrary functions of X .
Then I ( X 1 ; X 2 ) ≤ I ( X ; ( X 1 , X 2 )) .
Proof.
Follows by two applications of the data processing inequality , which states that for random variables X , Y and Z satisfying the Markov relation X
→ Y → Z , the inequality I ( X ; Z ) ≤
I ( X ; Y ) holds.
The ﬁrst step is to observe that X , X 1 and X 2 satisfy the relation X 1 ← X → X 2 , which is
Markov equivalent to X 1 → X → X 2 (in particular, X 1 and X 2 are conditionally independent given X ).
It therefore follows that I ( X 1 ; X 2 ) ≤ I ( X ; X 1 ) .
The second step is to observe that
X → ( X 1 , X 2 ) → X 1 and therefore I ( X ; X 1 ) ≤ I ( X ; ( X 1 , X 2 )) .
Combining the two inequalities yields I ( X 1 ; X 2 ) ≤ I ( X ; ( X 1 , X 2 )) , as required.
B E XPERIMENT DETAILS : A DVERSARIALLY TRAINED ENCODER (S ECTION 3.1)
In the following, we present the details for training the invertible model from Section 3.1 adversarially.
We model g 1 with the same RealNVP architecture as in the ﬁrst experiment, and do not model g 2 .
On top of g 1 ( X (1) ) we add a linear layer mapping to 10 outputs (i.e. logits).
The parameters of the linear layer trained by minimizing the cross-entropy loss with respect to the true label of X from which X (1) is derived.
Conversely, the parameters of the encoder g 1 are trained to minimize the cross-entropy loss with respect to a uniform probability vector over all 10 classes.
We use the Adam optimizer with a learning rate of 10 − 4 for the parameters of the classiﬁer and 10 − 6 for the parameters of the encoder, and perform 10 classiﬁer optimization steps per encoder step.
Furthermore, in a warm-up phase we train the classiﬁer for 1 k iterations before alternating between classiﬁer and encoder steps.
C C ONNECTION BETWEEN METRIC LEARNING AND I NFO NCE
I NCE can be rewritten as follows:
[Equation]
D I NFO NCE UNDER NON - I . I . D . SAMPLING
The proof that InfoNCE is a lower bound on MI presented in (Poole et al., 2019) makes crucial use of the assumption that the negative samples are drawn from the true marginal distribution.
We brieﬂy review this proof to highlight the importance of the negative sampling distribution.
Their proof starts from the NWJ lower bound of the KL divergence, namely that for any function ˜ f
the following lower bound holds (Nguyen et al., 2010;
Nowozin et al., 2016):
[Equation]
[ ˜ f ( x, y )] − e − 1 E p ( x ) p ( y )
[ e ˜ f ( x,y ) ] .
Suppose that ( X i , Y i )
Ki
=1 are i.i.d.
draws from p ( x, y ) and write X 1: K =
( X 1 , X 2 , . . .
, X K ) .
Then, for any i we have that I ( X 1: K ; Y i )
=
I ( X i ; Y i ) =
I ( X ; Y ) .
We thus have
[Equation]
where the equality follows from the assumption that the ( X i , Y i )
Ki
=1 are i.i.d.
and the inequality is (6) applied to I ( X 1: K ; Y i ) .
In particular, taking ˜ f
( x 1: K , y i )
= 1 + log e f ( xi,yi ) [Equation] f
[Equation]
,yi ) yields
[Equation]
This is then averaged over the K samples Y i , in which case the third term above cancels with the constant 1 (all occurences of y i in the last term of (7) can be replaced with y 1 thanks to ( X i , Y i ) being identically distributed), yielding the familiar I NCE lower bound:
[Equation]
The point in this proof that makes use of the i.i.d.
assumption of the negative samples is in the equality
I
( X i , Y i )
=
I ( X 1: K , Y i ) , which allowed us to leverage multiple samples when estimating the MI between two variables.
If instead the negative samples are drawn in a dependent fashion (corresponding to the ( X i , Y i ) being drawn identically but not independently ), we have I ( X i , Y i ) ≤
I ( X 1: K , Y i ) , though the remainder of the proof still holds, resulting in
[Equation]
Therefore the resulting I NCE estimator is neither a lower nor an upper bound on the true MI I ( X, Y ) .
E E XPERIMENT DETAILS : N ON - I . I . D . SAMPLING (S ECTION 4)
Recall that ( X, Y ) =
Z + (cid:15) .
We use Z ∼ N (0 , Σ Z ) and (cid:15) ∼ N (0 , Σ (cid:15) ) ,
where Σ Z = (cid:18)− 0 .− 0 .
(cid:19) and Σ (cid:15) =
(cid:18)0 .0 .
(cid:19) .
Batches of data are obtained as ( X i , Y i )
=
Z + (cid:15) i where each (cid:15) i is sampled independently for each element of the batch, but Z is sampled only once per batch.
The true MI I ( X, Y ) can be calculated analytically since ( X, Y ) is jointly Gaussian with known covariance matrix Σ Z + Σ (cid:15) :
For two univariate random variables ( X, Y ) that are jointly Gaussian with covariance Σ the MI can be written as
[Equation]
This can be derived using the decomposition I ( X, Y ) =
[Equation]
X )
[Equation] H ( Y ) − H ( X, Y ) and the analytic expression for the entropy H of a Gaussian.
We compare the same setting trained using i.i.d.
sampled pairs ( X i , Y i ) as a baseline.
We parametrize the critic as a MLP with 5 hidden layers, each with 10 units and ReLU activations, followed by a linear layer and maximize I NCE using these non- i.i.d.
samples with batch size 128.
Note that if a batch size of K is used, the bound I NCE ≤ log K always holds.
We used K sufﬁciently large so that
I ( X, Y ) ≤ log K to avoid I NCE trivially lower bounding the true MI.
[Figure] [Figure]
[Figure]
encoder architectures and MI estimators, using a bilinear critic trained to match a given target I EST of t (we minimize L t ( g 1 , g 2 )
=
| I EST ( g 1 ( X (1) ); g 1 ( X (2) ))
− t | ).
G R ESULTS FOR THE EXPERIMENTS FROM S EC . 3.2 AND 3.3 ON CIFAR
We run the experiments form Sections 3.2 and 3.3 on CIFAR10 with minimal changes.
Speciﬁcally, we use the same encoder and critic architectures with the only difference that the input layers of the encoders are adapted to process the (ﬂattened) 32 × 14 × 3 pixel image halves.
Furthermore, we reduce the learning rate from 10 − 4 to 10 − 5 and triple the number of training iterations.
Linear classiﬁcation in pixel space from the upper image halves achieves a testing accuracy of about 24% .
The CIFAR10 results for the experiment investigating the critic architecture (Section 3.2) can be found in Figure 8 and the results for the experiments investigating the encoder architecture (Section 3.3) in Figure 9.
The qualitative behavior of the different encoder and critic architectures in terms of downstream testing accuracy and testing I EST is very similar to the one observed for MNIST.
The conclusions made for MNIST hence carry over to CIFAR10.
[Figure] [Figure]