We investigate the problem of learning representations that are invariant to certain nuisance or sensitive factors of variation in the data while retaining as much of the remaining information as possible. Our model is based on a variational autoencoding architecture with priors that encourage independence between sensitive and latent factors of variation. Any subsequent processing, such as classification, can then be performed on this purged latent representation. To remove any remaining dependencies we incorporate an additional penalty term based on the "Maximum Mean Discrepancy" (MMD) measure. We discuss how these architectures can be efficiently trained on data and show in experiments that this method is more effective than previous work in removing unwanted sources of variation while maintaining informative latent representations.READ FULL TEXT VIEW PDF
In “Representation Learning” one tries to find representations of the data that are informative for a particular task while removing the factors of variation that are uninformative and are typically detrimental for the task under consideration. Uninformative dimensions are often called “noise” or “nuisance variables” while informative dimensions are usually called latent or hidden factors of variation. Many machine learning algorithms can be understood in this way: principal component analysis, nonlinear dimensional reduction and latent Dirichlet allocation are all models that extract informative factors (dimensions, causes, topics) of the data which can often be used to visualize the data. On the other hand, linear discriminant analysis and deep (convolutional) neural nets learn representations that are good for classification.
In this paper we consider the case where we wish to learn latent representations where (almost) all of the information about certain known factors of variation are purged from the representation while still retaining as much information about the data as possible. In other words, we want a latent representation
that is maximally informative about an observed random variable(e.g., class label) while minimally informative about a sensitive or nuisance variable . By treating as a sensitive variable, i.e. is correlated with our objective, we are dealing with “fair representations”, a problem previously considered by Zemel et al. (2013). If we instead treat as a nuisance variable we are dealing with “domain adaptation”, in other words by removing the domain from our representations we will obtain improved performance.
In this paper we introduce a novel model based on deep variational autoencoders (VAE) (Kingma & Welling, 2014; Rezende et al., 2014). These models can naturally encourage separation between latent variables and sensitive variables by using factorized priors
. However, some dependencies may still remain when mapping data-cases to their hidden representation using the variational posterior, which we stamp out using a “Maximum Mean Discrepancy” (Gretton et al., 2006)
term that penalizes differences between all order moments of the marginal posterior distributionsand (for a discrete RV ). In experiments we show that this combined approach is highly successful in learning representations that are devoid of unwanted information while retaining as much information as possible from what remains.
Factoring out undesired variations from the data can be easily formulated as a general probabilistic model which admits two distinct (independent) “sources”; an observed variable , which denotes the variations that we want to remove, and a continuous latent variable which models all the remaining information. This generative process can be formally defined as:
is an appropriate probability distribution for the data we are modelling. With this formulation we explicitly encode a notion of ‘invariance’ in our model, since the latent representation is marginally independent of the factors of variation. Therefore the problem of finding an invariant representation for a data point and variation can be cast as performing inference on this graphical model and obtaining the posterior distribution of , .
For our model we will employ a variational autoencoder architecture (Kingma & Welling, 2014; Rezende et al., 2014); namely we will parametrize the generative model (decoder) and the variational posterior (encoder)
as (deep) neural networks which accept as inputsand
respectively and produce the parameters of each distribution after a series of non-linear transformations. Both the model () and variational () parameters will be jointly optimized with the SGVB (Kingma & Welling, 2014) algorithm according to a lower bound on the log-likelihood. This parametrization will allow us to capture most of the salient information of in our embedding
. Furthermore the distributed representation of a neural network would allow us to better resolve the dependencies betweenand thus yielding a better disentangling between the independent factors and . By choosing a Gaussian posterior and standard isotropic Gaussian prior we can obtain the following lower bound:
with and with being an appropriate probability distribution for the data we are modelling.
Factoring out variations in an unsupervised way can however be harmful in cases where we want to use this invariant representation for a subsequent prediction task. In particular if we have a situation where the nuisance variable and the actual label are correlated, then training an unsupervised model could yield random or degenerate representations with respect to
. Therefore it is more appropriate to try to “inject” the information about the label during the feature extraction phase. This can be quite simply achieved by introducing a second “layer” of latent variables to our generative model where we try to correlatewith the prediction task. Assuming that the invariant features are now called we enrich the generative story by similarly providing two distinct (independent) sources for ; a discrete (in case of classification)variable which denotes the label of the data point and a continuous latent variable which encodes the variation on that is not explained by ( dependent noise). The process now can be formally defined as:
Similarly to the unsupervised case we use a variational auto-encoder and jointly optimize the variational and model parameters. The lower bound now becomes:
where we assume that the posterior is factorized as , and where:
with again being an appropriate probability distribution for the data we are modelling. The model proposed here can be seen as an extension to the ‘stacked M1+M2’ model originally proposed from Kingma et al. (2014), where we have additionally introduced the nuisance variable during the feature extraction. Thus following Kingma et al. (2014)
we can also handle the ‘semi-supervised’ case, i.e., missing labels. In situations where the label is observed the lower bound takes the following form (exploiting the fact that we can compute some Kullback-Leibler divergences explicitly in our case):
and in the case that it is not observed we use
to ‘impute’ our data:
therefore the final objective function is:
where the last term is introduced so as to ensure that the predictive posterior learns from both labeled and unlabeled data. This semi-supervised model will be called “VAE” in our experiments.
However, there is a subtle difference between the approach of Kingma et al. (2014) and our model. Instead of training separately each layer of stochastic variables we optimize the model jointly. The potential advantages of this approach are two fold: as we previously mentioned if the label and the nuisance information are correlated then training a (conditional) feature extractor separately poses the danger of creating a degenerate representation with respect to the label . Furthermore the label information will also better guide the feature extraction towards the more salient parts of the data, thus maintaining most of the (predictive) information.
Despite the fact that we have a model that encourages statistical independence between and a-priori we might still have some dependence in the (approximate) marginal posterior . In particular, this can happen if the label is correlated with the sensitive variable , which can allow information about to “leak” into the posterior. Thus instead we could maximize a “penalized” lower bound where we impose some sort of regularization on the marginal . In the following we will describe one way to achieve this regularization through the Maximum Mean Discrepancy (MMD) (Gretton et al., 2006) measure.
Consider the problem of determining whether two datasets and are drawn from the same distribution, i.e., . A simple test is to consider the distance between empirical statistics of the two datasets:
Expanding the square yields an estimator composed only of inner products on which the kernel trick can be applied. The resulting estimator is known as Maximum Mean Discrepancy (MMD)(Gretton et al., 2006):
Asymptotically, for a universal kernel such as the Gaussian kernel , is if and only if . Equivalently, minimizing MMD can be viewed as matching all of the moments of and . Therefore, we can use it as an extra “regularizer” and force the model to try to match the moments between the marginal posterior distributions of our latent variables, i.e., and (in the case of binary nuisance information 111In case that we have more than two states for the nuisance information , we minimize the MMD penalty between each marginal and , i.e., for all possible states of .). By adding the MMD penalty into the lower bound of our aforementioned VAE architecture we obtain our proposed model, the “Variational Fair Autoencoder” (VFAE):
A naive implementation of MMD in minibatch stochastic gradient descent would require computing theGram matrix for each minibatch during training, where is the minibatch size. Instead, we can use random kitchen sinks (Rahimi & Recht, 2009) to compute a feature expansion such that computing the estimator approximates the full MMD (7). To compute this, we draw a random matrix , where is the dimensionality of , is the number of random features and each entry of is drawn from a standard isotropic Gaussian. The feature expansion is then given as:
where is a
-dimensional uniform random vector with entries in. Zhao & Meng (2015) have successfully applied the idea of using random kitchen sinks to approximate MMD. This estimator is fairly accurate, and is typically much faster than the full MMD penalty. We use in our experiments.
We performed experiments on the three datasets that correspond to a “fair” classification scenario and were previously used by Zemel et al. (2013). In these datasets the “nuisance” or sensitive variable is significantly correlated with the label thus making the proper removal of challenging. Furthermore, we also experimented with the Amazon reviews dataset to make a connection with the “domain-adaptation” literature. Finally, we also experimented with a more general task on the extended Yale B dataset; that of learning invariant representations.
For the fairness task we experimented with three datasets that were previously used by Zemel et al. (2013). The German dataset is the smallest one with data points and the objective is to predict whether a person has a good or bad credit rating. The sensitive variable is the gender of the individual. The Adult income dataset contains entries and describes whether an account holder has over dollars in their account. The sensitive variable is age. Both of these are obtained from the UCI machine learning repository (Frank & Asuncion, 2010). The health dataset is derived from the Heritage Health Prize222www.heritagehealthprize.com. It is the largest of the three datasets with entries. The task is to predict whether a patient will spend any days in the hospital in the next year and the sensitive variable is the age of the individual. We use the same train/test/validation splits as Zemel et al. (2013), where
is the sigmoid function333.
For the domain adaptation task we used the Amazon reviews dataset (with similar preprocessing) that was also employed by Chen et al. (2012) and Ganin et al. (2015). It is composed from text reviews about particular products, where each product belongs to one out of four different domains: “books”, “dvd”, “electronics” and “kitchen”. As a result we performed twelve domain adaptation tasks. The labels correspond to the sentiment of each review, i.e. either positive or negative. Since each feature vector
is composed from counts of unigrams and bigrams we used a Poisson distribution for. It is also worthwhile to mention that we can fully exploit the semi-supervised nature of our model in this dataset, and thus for training we only use the source domain labels and consider the labels of the target domain as “missing”.
For the general task of learning invariant representations we used the Extended Yale B dataset, which was also employed in a similar fashion by Li et al. (2014). It is composed from face images of 38 people under different lighting conditions (directions of the light source). Similarly to Li et al. (2014), we created 5 states for the nuisance variable : light source in upper right, lower right, lower left, upper left and the front. The labels correspond to the identity of the person. Following Li et al. (2014), we used the same training, test set and no validation set. For the distribution we used a Gaussian with means constrained in the 0-1 range (since we have intensity images) by a sigmoid, i.e. .
For the Adult dataset both encoders, for and , and both decoders, for and , had one hidden layer of 100 units. For the Health dataset we had one hidden layer of 300 units for the encoder and decoder and one hidden layer of 150 units for the encoder and decoder. For the much smaller German dataset we used 60 hidden units for both encoders and decoders. Finally, for the Amazon reviews and Extended Yale B datasets we had one hidden layer with 500, 400 units respectively for the encoder, decoder, and 300, 100 units respectively for the encoder and decoder. On all of the datasets we used 50 latent dimensions for and , except for the small German dataset, where we used 30 latent dimensions for both variables. For the predictive posterior2015)
using the default values for the hyperparameters, minibatches of 100 data points and temporal averaging. The MMD penalty was simply multiplied by the minibatch size so as to keep the scale of the penalty similar to the lower bound. Furthermore, the extra strength of the MMD,, was tuned according to a validation set. The scaling of the supervised cost was low () for the Adult, Health and German datasets due to the correlation of with . On the Amazon reviews and Extended Yale B datasets however the scaling of the supervised cost was higher: for the Amazon reviews dataset (empirically determined after observing the classification loss on the first few iterations on the first source-target pair) and for the Extended Yale B dataset. Similarly, the scaling of the MMD penalty was for the Amazon reviews dataset and for the Extended Yale B.
Our evaluation is geared towards two fronts; removing information about and classification accuracy for . To measure the information about in our new representation we simply train a classifier to predict from
. We utilize both Logistic Regression (LR) which is a simple linear classifier, and Random Forest (RF) which is a powerful non-linear classifier. Since on the datasets that we experimented with the nuisance variableis binary we can easily find the random chance accuracy for and measure the discriminatory information of in . Furthermore, we also used the discrimination metric from Zemel et al. (2013) as well a more “informed” version of the discrimination metric that instead of the predictions, takes into account the probabilities of the correct class. They are provided in the appendix A. Finally, for the classification performance on we used the predictive posterior for the VAE/VFAE and a simple Logistic Regression for the original representations . It should be noted that for the VFAE and VAE models we use a sample from to make predictions, instead of using the mean. We found that the extra noise helps with invariance.
We implemented the Learning Fair Representations (Zemel et al., 2013) method (LFR) as a baseline using dimensions for the latent space. To measure the accuracy on in the results below we similarly used the LFR model predictions.
The results for all three datasets can be seen in Figure 3. Since we are dealing with the “fair” classification scenario here, low accuracy and discrimination against is more important than the accuracy on (as long as we do not produce degenerate representations).
On the Adult dataset, the highest accuracy on the label and the lowest discrimination against is obtained by our LFR baseline. Despite the fact that LFR appears to give the best tradeoff between accuracy and discrimination, it appears to retain information about in its representation, which is discovered from the random forest classifier. In that sense, the VFAE method appears to do the best job in actually removing the sensitive information and maintaining most of the predictive information. Furthermore, the introduction of the MMD penalty in the VFAE model seems to provide a significant benefit with respect to our discrimination metrics, as both were reduced considerably compared to the regular VAE.
On the German dataset, all methods appear to be invariant with respect to the sensitive information . However this is not the case for the discrimination metric, since LFR does appear to retain information compared to the VAE and VFAE. The MMD penalty in VFAE did seem improve the discrimination scores over the original VAE, while the accuracy on the labels remained similar.
As for the Health dataset; this dataset is extremely imbalanced, with only 15% of the patients being admitted to a hospital. Therefore, each of the classifiers seems to predict the majority class as the label for every point. For the invariance against however, the results were more interesting. On the one hand, the VAE model on this dataset did maintain some sensitive information, which could be identified both linearly and non-linearly. On the other hand, VFAE and the LFR methods were able to retain less information in their latent representation, since only Random Forest was able to achieve higher than random chance accuracy. This further justifies our choice for including the MMD penalty in the lower bound of the VAE. .
In order to further assess the nature of our new representations, we visualized two dimensional Barnes-Hut SNE (van der Maaten, 2013) embeddings of the representations, obtained from the model trained on the Adult dataset, in Figure 4. As we can see, the nuisance/sensitive variables can be identified both on the original representation and on a latent representation that does not have the MMD penalty and the independence properties between and in the prior. By introducing these independence properties as well as the MMD penalty the nuisance variable groups become practically indistinguishable.
As for the domain adaptation scenario and the Amazon reviews dataset, the results of our VFAE model can be seen in Table 1. Our model was successful in factoring out the domain information, since the accuracy, measured both linearly (LR) and non-linearly (RF), was towards random chance (which for this dataset is 0.5). We should also mention that, on this dataset at least, completely removing information about the domain does not guarantee a better performance on . The same effect was also observed by Ganin et al. (2015) and Chen et al. (2012). As far as the accuracy on is concerned, we compared against a recent neural network based state of the art method for domain adaptation, Domain Adversarial Neural Network (DANN) (Ganin et al., 2015). As we can observe in table 1, our accuracy on the labels is higher on 9 out of the 12 domain adaptation tasks whereas on the remaining 3 it is quite similar to the DANN architecture.
|Source - Target||S||Y|
|books - dvd||0.535||0.564||0.799||0.784|
|books - electronics||0.541||0.562||0.792||0.733|
|books - kitchen||0.537||0.583||0.816||0.779|
|dvd - books||0.537||0.563||0.755||0.723|
|dvd - electronics||0.538||0.566||0.786||0.754|
|dvd - kitchen||0.543||0.589||0.822||0.783|
|electronics - books||0.562||0.590||0.727||0.713|
|electronics - dvd||0.556||0.586||0.765||0.738|
|electronics - kitchen||0.536||0.570||0.850||0.854|
|kitchen - books||0.560||0.593||0.720||0.709|
|kitchen - dvd||0.561||0.599||0.733||0.740|
|kitchen - electronics||0.533||0.565||0.838||0.843|
Regarding the more general task of learning invariant representations; our results on the Extended Yale B dataset also demonstrate our model’s ability to learn such representations. As expected, on the original representation the lighting conditions, , are well identifiable with almost perfect accuracy from both RF and LR. This can also be seen in the two dimensional embeddings of the original space in Figure 4(a): the images are mostly clustered according to the lighting conditions. As soon as we utilize our VFAE model we simultaneously decrease the accuracy on , from 96% to about 50%, and increase our accuracy on , from 78% to about 85%. This effect can also be seen in Figure 4(b): the images are now mostly clustered according to the person ID (the label ). It is clear that in this scenario the information about is purely “nuisance” with respect to the labels . Therefore, by using our VFAE model we are able to obtain improved generalization and classification performance by effectively removing from our representations.
|NN + MMD||-||-||0.82|
Most related to our “fair” representations view is the work from Zemel et al. (2013). They proposed a neural network based semi-supervised clustering model for learning fair representations. The idea is to learn a localised representation that maps each datapoint to a cluster in such a way that each cluster gets assigned roughly equal proportions of data from each group in . Although their approach was successfully applied on several datasets, the restriction to clustering means that it cannot leverage the representational power of a distributed representation. Furthermore, this penalty does not account for higher order moments in the latent distribution. For example, if always returns or , while returns values between values and , then the penalty could still be satisfied, but information could still leak through. We addressed both of these issues in this paper.
Domain adaptation can also be cast as learning representations that are “invariant” with respect to a discrete variable , the domain. Most similar to our work are neural network approaches which try to match the feature distributions between the domains. This was performed in an unsupervised way with mSDA (Chen et al., 2012)
by training denoising autoencoders jointly on all domains, thus implicitly obtaining a representation general enough to explain both the domain and the data. This is in contrast to our approach where we instead try to learn representations that explicitly remove domain information during the learning process. For the latter we find more similarities with “domain-regularized” supervised approaches that simultaneously try to predict the label for a data point and remove domain specific information. This is done with either MMD(Long & Wang, 2015; Tzeng et al., 2014) or adversarial (Ganin et al., 2015) penalties at the hidden layers of the network. In our model however the main “domain-regularizer” stems from the independence properties of the prior over the domain and latent representations. We also employ MMD on our model but from a different perspective since we consider a slightly more difficult case where the domain and label are correlated; we need to ensure that we remain as “invariant” as possible since might ‘leak’ information about .
We introduce the Variational Fair Autoencoder (VFAE), an extension of the semi-supervised variational autoencoder in order to learn representations that are explicitly invariant with respect to some known aspect of a dataset while retaining as much remaining information as possible. We further use a Maximum Mean Discrepancy regularizer in order to further promote invariance in the posterior distribution over latent variables. We apply this model to tasks involving developing fair classifiers that are invariant to sensitive demographic information and show that it produces a better tradeoff with respect to accuracy and invariance. As a second application, we consider the task of domain adaptation, where the goal is to improve classification by training a classifier that is invariant to the domain. We find that our model is competitive with recently proposed adversarial approaches. Finally, we also consider the more general task of learning invariant representations. We can observe that our model provides a clear improvement against a neural network that incorporates a Maximum Mean Discrepancy penalty.
Stochastic backpropagation and approximate inference in deep generative models.International Conference on Machine Learning (ICML), 2014.
The Discrimination metric (Zemel et al., 2013) and the Discrimination metric that takes into account the probabilities of the correct class are mathematically formalized as:
where for the predictions that were done on the datapoints with nuisance variable , denotes the total amount of datapoints that had nuisance variable and denotes the probability of the prediction for the datapoints with . For the predictions and their respective probabilities we used a Logistic Regression classifier.
Similarly to Ganin et al. (2015)
, we also calculated the Proxy A-distance (PAD)(Ben-David et al., 2007, 2010) scores for the raw data and for the representations of VFAE. Briefly, Proxy A-distance is an approximation to the -divergence measure of domain distinguishability proposed in Kifer et al. (2004) and Ben-David et al. (2007, 2010). To compute it we first need to train a learning algorithm on the task of discriminating examples from the source and target domain. Afterwards we can use the test error of that algorithm in the following formula:
It is clear that low PAD scores correspond to low discrimination of the source and target domain examples from the classifier. To obtain for our model we used Logistic Regression. The resulting plot can be seen in Figure 6, where we have also added the plot from DANN (Ganin et al., 2015)
, where they used a linear Support Vector Machine for the classifier, as a reference. It can be seen that our VFAE model can factor out the information aboutbetter, since the PAD scores on our new representation are, overall, lower than the ones obtained from the DANN architecture.