# Generative Models For Deep Learning with Very Scarce Data

Juan Maroñas<EMAIL_ADDRESS>correspondence to: Juan Maroñas
$<$jmaronas<EMAIL_ADDRESS>Work published at 23th
Iberoamerican Congress on Pattern Recognition Pattern Recognition and Human
Language Technology, Universitat Politècnica de València, Valencia , Spain
Roberto Paredes<EMAIL_ADDRESS>Pattern Recognition and Human Language
Technology, Universitat Politècnica de València, Valencia , Spain  Daniel
Ramos<EMAIL_ADDRESS>AUDIAS , Universidad Autónoma de Madrid, Madrid,
Spain

(November 2018)

###### Abstract

The goal of this paper is to deal with a data scarcity scenario where deep
learning techniques use to fail. We compare the use of two well established
techniques, Restricted Boltzmann Machines and Variational Auto-encoders, as
generative models in order to increase the training set in a classification
framework. Essentially, we rely on Markov Chain Monte Carlo (MCMC) algorithms
for generating new samples. We show that generalization can be improved
comparing this methodology to other state-of-the-art techniques, e.g. semi-
supervised learning with ladder networks. Furthermore, we show that RBM is
better than VAE generating new samples for training a classifier with good
generalization capabilities.

Keywords: Data Scarcity, Generative Models, Data augmentation, Markov Chain
Monte Carlo algorithms

##  1 Introduction

In the last few years deep neural networks have achieved state-of-the-art
performance in many task such as image recognition [17], object recognition
[13], language modeling [10], machine translation [16] or speech recognition
[7]. One of the key facts that increased this performance is the great amount
of available data. This amount of data together with the high expressiveness
of neural networks as functions approximators and appropriate hardware lead us
to an unprecedented performance in challenging problems.

However, deep learning lacks of success in scenarios where the amount of
labeled data is scarce. In this work we aim at providing a methodology in
order to apply deep learning techniques to problems with _very_ scarce
available data. Some techniques are proposed to deal with such data size
problem: semi supervised learning techniques such as the ladder network [12],
Bayesian modeling [5] and data augmentation (DA) [18]. In particular, data
augmentation uses to be referred to the techniques where the practitioners
know the most common data variability, as in image recognition, and these
variations can be applied to the available data in order to obtain new
samples. On the other hand, there are other methods not assisted by
practitioners to generate new samples: generative adversarial networks, GANs
[6], variational models such as variational auto-encoder VAE [14, 9] and
autoregressive models [19].

Figure 1: Samples obtained by decoding a sample from the prior distribution
with two VAEs trained on 100 (top left) and 60000 (top right) samples from the
MNIST database. Below we plot the reconstruction error (red dashed line)
showing that although we are minimizing it, we cannot generate good quality
images. Acronyms: $ELBO$ evidence lower bound; $D_{KL}$ Kullback-Lieber
divergence and $LLH$ log-likelihood.

In this work we study how we can apply deep learning techniques when the
amount of data is very scarce. We simulate scenarios where not only the amount
of labeled data is scarce, but all the available data. As mentioned before,
some techniques can deal with such scenarios. Bayesian modeling incorporates
the uncertainty in the model [3]. However Bayesian neural networks are a field
under study and introduce several problems for which there is not a wide well
established solution: Monte Carlo integration, variational approximations or
sampling in high dimensional data spaces, among others.

On the other hand, semi supervised learning techniques need a great amount of
unlabeled data to work well. For instance, the ladder network can achieve
impressive results with only 100 labeled samples in the MNIST task but using
60000 unlabeled samples.

Finally, deep generative models (DGM) need great amounts of data to be able of
generate good quality samples. Figure 1 shows a Variational Auto-encoder (VAE)
trained with 100 and 60000 samples. We can see that although the
reconstruction error is being minimized the VAE with few samples is unable to
generate good samples.

To our knowledge, none of the above mentioned techniques (both semi supervised
and DA with DGM) has been applied disruptively to train neural networks models
in data scarce scenarios as the ones we propose. Moreover DA based on DGM has
not achieved impressive results in neural networks training with lots of data.

In this work we show that simple generative models as the Restricted Boltzmann
Machines (RBM) [1] clearly outperforms the ladder network and DA based on a
Deep Convolutional Variational Auto-encoder.

##  2 Methodology

In this work we simulate very scarce data scenarios. We train binary VAE and
RBM using all the available samples. Details on these models can be found at
[1, 9, 14]. Once these models are trained, we perform a sample generation
following a MCMC procedure.

###  2.1 Sample Generation

For sample generation we rely on the theory of MCMC algorithms and define our
transition operator as:

$\mathcal{T}(x^{\prime}|x)=\int dh\,p(x^{\prime}|h)\cdot p(h|x)$ (1)

Where $p(x^{\prime}|h)$ and $p(h|x)$ represents the likelihood distribution of
an observed sample $x$ given a latent variable $h$ and, the posterior
distribution over the latent variable given an observed sample, respectively.
We will assume that this transition operator generates an ergodic Markov Chain
and thus as long as the number of generated samples goes to infinity we will
be sampling from the model distribution $p(x)$ [11, 3, 2]. In case of VAEs,
where the posterior distribution is approximated, see [14] appendix F for a
proof of correctness.

In our models the likelihood distribution $p(x|h)$ is modeled with a Bernoulli
distribution. The posterior distribution is modeled with a Bernoulli
distribution for the RBM and with a factorized Gaussian distribution for the
VAE. For generating a sample we follow the Contrastive Divergence [4]
algorithm which is based on Gibbs Sampling but starting from an observed
sample. As example for generating 100 samples we follow algorithm 1, where $x$
is a sample from our dataset from which we will be generating new samples and
$N$ is the number of samples to generate.111In case of VAE $p(h|x)$ is
replaced by $q(h|x)$ which is the Variational Distribution. Note that although
a Gibbs sampler depends on all the previous generated dimensions of a sample,
in this case we can sample all the feature dimensions in parallel and thus our
method is highly efficient.

Input: $x$ , $N$

Output: generated_chain

generated_chain=vector($N$)

$x^{\prime}=x$

for  _$i=0$ until $N-1$ _ do

$h^{\prime}\sim p(h|x^{\prime})$

$x^{\prime}\sim p(x|h^{\prime})$

generated_chain[$i$]$=x^{\prime}$

end for

Algorithm 1 Running MCMC algorithm for data generation

Figure 2: This figure shows $\mathbb{E}_{x\sim p(x|h)}\\{x\\}$ of a Markov
Chain run with a VAE trained on 60000 samples, starting from a test image
(image on the top left corner). We can clearly see how the generated samples
can change from class as we run the algorithm. Image in the middle starts from
an 8, then, the two next generated samples are 9s to after generate 8s and
finally generate 3s. Sample on the right starts from a 5, generate some 5s and
finally generate 0s.

###  2.2 Labeling process

We use the generated samples in two ways. As we stated, our approach is based
on training a classifier on a set of labeled samples using additional
generated samples from a VAE or a RBM. We associate the generated samples with
the same label as the sample from the data distribution. In a first approach
we use all the generated samples (and denote this approach in the experiments
with letter $n$). In the second approach we classify the samples from the
chain (using the same classifier we are training) and only the correctly
classified samples are used for training (we denote this approach in the
experiments with letter $y$). This has a great impact, as shown in the
experiments, because long Markov Chains are likely to generate samples from
other classes, as shown in figure 2.

Moreover, in case of the RBM we train two kind of models, named B-RBM (”bad
RBM”) and G-RBM (”good RBM”). The difference rely on the convergence of the
model, i.e., how is the quality of the generated samples, see figure 3. We
expect that with a B-RBM the injected noise is able to improve the
generalization whereas the G-RBM is collapsing to a part of the model space
where no generalization improvement will be obtained. Basically we do not let
the model achieve the same minimum for the case of the B-RBM as we do with the
G-RBM.

Figure 3: Samples from a bad (left) and good (right) RBM. Figure shows a
sample from a MCMC chain of 1 step starting from a test sample.

Finally, figure 4 shows images from the different trained models in this work.
We can clearly see how the VAE is able to generate good quality samples only
when more training samples are provided.

(a) B-RBM trained with 100 samples (left) and 1000 samples (right).

(b) G-RBM trained with 100 samples (left) and 1000 samples (right).

(c) Samples from a VAE trained with 100 samples (left), 1000 samples (middle
left), 10000 samples (middle right) and $\mathbb{E}_{x\sim p(x|h)}\\{x\\}$ on
10000 samples (right)

Figure 4: Samples from our proposed generative models

##  3 Experiments

For the experiments we use a binarized version from the MNIST database. This
database has 60000 training samples and 10000 test samples. The pixels above
$0.5$ are saturated to value $1.0$ and the rest are saturated to $0.0$. In
order to simulate a scarce data scenario, we randomly select a small set of
samples, and assume that only a very small subset is labeled. We simulate
three different scenarios with a total of $100$, $1000$ and $10000$ samples
where only $10$, $100$ and $1000$ are labeled respectively. Note that for the
first scenario we have only $1$ labeled sample per class.

We use a binarized version of this database because, the expressions of the
conditional distributions of the RBM models we use, are obtained assuming
binary data distributions. Moreover, the VAE models for MNIST converge better
when using Bernoulli decoders , ie binary cross entropy loss.

We trained 3 models, two fully connected (FC) and one convolutional (CNN). For
fully connected we choose the following parameters, FC1: 784-1024-1024-10,
FC2: 784-1000-500-250-250-250-10. For the convolutional counterpart we use,
CONV1: 32@3x3-64@3x3-128@3x3-512-512-10. In all the topologies we inject
Gaussian noise with $\sigma=0.3$ in the input and we use batch norm (BN)[8]
and dropout [15])

Tables 1, 2 and 3 show the error percentage with the here proposed data
augmentation showing that the B-RBM clearly outperforms other approaches. We
generate Markov chains of 500 and 1000 samples to increase the data set and
train the classifier222convolutional models on 10 labeled samples are trained
with 850 instead of 1000 samples. Convolutional models for 100 and 1000
samples use chains of 100 samples. VAE model on 100 and 1000 samples for all
the schemes generates 100 samples. We found a GPU-memory bottleneck because we
performed a parameter update per batch with all its generated samples. It is
interesting to see that although the deep FC (FC2) has worse performance than
FC1 with 10 and 100 samples without DA, we can achieve better results in case
of 100 samples with FC2 when using our proposed method.

We also see that a significant improvement is obtained with the most scarce
scenario (see table 1), where we are able to reduce 17% error on CONV1 (check
B-RBM option $y$ 1000 samples) and more than 10% in FC models (check B-RBM
option $y$), which is the main objective of this work.

Table 1: Data Augmentation for 10 labeled samples

Baseline B-RBM G-RBM VAE Chain Length 500 1000 500 1000 500 1000 Classify y n
y n y n y n y n y n FC1 53.71 44.71 47.87 43.19 47.56 53.49 52.55 53.91 52.5
80.25 51.49 84.48 50.56 FC2 58.88 45.34 47.18 46.4 46.26 54.74 55.27 57.43
57.96 78.14 56.91 78.79 56.66 CONV1 49.58 33.77 37.51 32.26 36.69 41.260 38.94
40.12 40.66 39.35 41.56 44.86 41.47

Table 2: Data Augmentation for 100 labeled samples

Baseline B-RBM G-RBM VAE Chain Length 500 1000 500 1000 500 1000 Classify y n
y n y n y n y n y n FC1 26.56 21.34 21.61 21.41 22.43 26.83 26.51 28.41 26.86
52.01 37.00 - - FC2 28.39 19.72 21.31 18.66 22.31 26.95 26.98 25.96 26.54
64.82 43.99 - - CONV1 12.41 11.65 13.55 - - 11.36 11.25 - - 58.35 30.14 - -

Table 3: Data Augmentation for 1000 labeled samples

Baseline B-RBM G-RBM VAE Chain Length 500 1000 500 1000 500 1000 Classify y n
y n y n y n y n y n FC1 7.62 5.55 6.16 5.81 6.04 5.86 5.91 5.79 5.97 24.13
12.42 - - FC2 7.25 5.60 5.96 5.76 5.62 5.28 5.40 4.70 5.49 36.19 18.00 - -
CONV1 3.11 3.26 3.89 - - 3.09 3.54 - - 10.19 4.85 - -

Finally, Table 4 shows a comparison with the ladder network. Ladder network
can be considered the state-of-the art on semi-supervised learning on this
dataset333Recently other proposed methods have achieved better results, but
they are based on GANs and we showed here that DGM are not suitable for these
scenarios. For that reason we compare with ladder network.. As can be seen we
obtain better results on the three scenarios.

Table 4: A comparison with the ladder network. We represent error percentage. Labeled Samples | 10 | 100 | 1000
---|---|---|---
Baseline | 58.88 | 28.39 | 7.25
Ladder Network | 48.85 | 24.74 | 6.96
RBM DA | 45.34 | 18.66 | 5.60

##  4 Conclusions

We can draw several conclusions from this work. We first show that in data
scarcity scenarios simple generative models outperform deep generative models
(like VAEs). We also see that a B-RBM is incorporating noise that is improving
generalization. We can check that G-RBM and VAE works better when we do not
classify the generated sample and this is in fact another way to incorporate
noise into the classifier. However B-RBM is the best of the three. This also
means that a generative model trained in this way (where latent variables
capture high detail) is unable to generate samples that improve
generalization. The G-RBM generates better quality images but is unable to
improve classification accuracy as the B-RBM does.

This can also be noted when we add more training samples, where the difference
between the baseline and the here proposed DA is lower, as with CNN. This is
because the samples generated do not incorporate additional information to the
model and are either quite similar between them or quite similar to the
labeled samples. A possible hypothesis is that the generative model is
collapsing to a part of the data feature space.

VAEs results were unexpected because despite the poor quality images generated
it can improve performance over the baseline. We got this improvement always
without classifying images, model $n$, and only in the case where few label
samples are used. It is clear that the VAE is not a good model for these
scenarios.

Finally, we also show that the here proposed approach outperforms and is
clearly an alternative to semi supervised learning in data scarcity scenarios
as shown in table 4. Another important advantage is that RBM is robust and has
a stable learning whether the ladder network and GAN frameworks have several
training challenges. The ladder network has many hyper-parameters and its
performance is really sensible to little changes on them and the GANs are
quite sensible to hyper-parameters as well.

##  5 Acknowledgment

We gratefully acknowledge the support of NVIDIA Corporation with the donation
of two Titan Xp GPU used for this research. The work of Daniel Ramos has been
supported by the Spanish Ministry of Education by project
TEC2015-68172-C2-1-P. Juan Maroñas is supported by grant FPI-UPV.

## References

  * [1] Y. Bengio.  Learning deep architectures for ai.  Found. Trends Mach. Learn., 2(1):1–127, Jan. 2009.
  * [2] Y. Bengio et al.  Generalized denoising auto-encoders as generative models.  In Advances in Neural Information Processing Systems 26, pages 899–907. Curran Associates, Inc., 2013.
  * [3] C. M. Bishop.  Pattern Recognition and Machine Learning.  Springer-Verlag, 2006.
  * [4] Carreira-Perpinan et al.  On contrastive divergence learning.  In Aistats, volume 10, pages 33–40. Citeseer, 2005.
  * [5] Y. Gal and Z. Ghahramani.  Bayesian convolutional neural networks with Bernoulli approximate variational inference.  In 4th International Conference on Learning Representations (ICLR) workshop track, 2016.
  * [6] I. Goodfellow et al.  Generative adversarial nets.  In Advances in Neural Information Processing Systems 27, pages 2672–2680. Curran Associates, Inc., 2014.
  * [7] G. Hinton et al.  Deep neural networks for acoustic modeling in speech recognition.  IEEE Signal Processing Magazine, 29:82–97, 2012.
  * [8] S. Ioffe et al.  Batch normalization: Accelerating deep network training by reducing internal covariate shift.  In Proceedings of the 32Nd International Conference on International Conference on Machine Learning - Volume 37, ICML’15, pages 448–456. JMLR.org, 2015.
  * [9] D. P. Kingma et al.  Auto-encoding variational bayes, 2013.
  * [10] T. Mikolov et al.  Efficient estimation of word representations in vector space.  2013\.
  * [11] R. M. Neal.  Probabilistic inference using markov chain monte carlo methods.  1993\.
  * [12] A. Rasmus et al.  Semi-supervised learning with ladder networks.  In Advances in Neural Information Processing Systems 28, pages 3546–3554. Curran Associates, Inc., 2015.
  * [13] J. Redmon et al.  You only look once: Unified, real-time object detection.  In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pages 779–788, 2016.
  * [14] D. J. Rezende et al.  Stochastic backpropagation and approximate inference in deep generative models.  In Proceedings of the 31st International Conference on International Conference on Machine Learning - Volume 32, ICML’14, pages II–1278–II–1286. JMLR.org, 2014.
  * [15] N. Srivastava et al.  Dropout: A simple way to prevent neural networks from overfitting.  Journal of Machine Learning Research, 15:1929–1958, 2014.
  * [16] I. Sutskever et al.  Sequence to sequence learning with neural networks.  In Advances in Neural Information Processing Systems 27, pages 3104–3112. Curran Associates, Inc., 2014.
  * [17] C. Szegedy et al.  Inception-v4, inception-resnet and the impact of residual connections on learning.  2016\.
  * [18] Tran et al.  A bayesian data augmentation approach for learning deep models.  In I. Guyon et al., editors, Advances in Neural Information Processing Systems 30, pages 2797–2806. Curran Associates, Inc., 2017.
  * [19] A. van den Oord et al.  Conditional image generation with pixelcnn decoders.  In Advances in Neural Information Processing Systems 29, pages 4790–4798. Curran Associates, Inc., 2016.


# Classification for everyone : Building geography agnostic models for fairer
recognition

Akshat Jindal
<EMAIL_ADDRESS>Shreya Singh
<EMAIL_ADDRESS>Soham Gadgil
<EMAIL_ADDRESS>
###### Abstract

In this paper, we analyze different methods to mitigate inherent geographical
biases present in state of the art image classification models. We first
quantitatively present this bias in two datasets - The Dollar Street Dataset
and ImageNet, using images with location information. We then present
different methods which can be employed to reduce this bias. Finally, we
analyze the effectiveness of the different techniques on making these models
more robust to geographical locations of the images.

##  1 Introduction

Recent advancements in GPUs and ASICs like TPU, resulting in increased
computational power, have led to many object recognition systems achieving
state of the art performance on publicly available datasets like ImageNet [3],
COCO [10], and OpenImages [7]. However, these systems seem to be biased toward
images obtained from well-developed western countries, partly because of the
skewed distribution of the geographical source location of such images [2]. As
such, these systems do not perform well on images from non-western countries
with low income. With such systems being deployed globally for use in many
real-world downstream applications, there is a need to make our systems more
robust to various geographies. Our project focuses on analyzing domain
adaptation techniques to close this performance gap, leading to more robust
and fairer object recognition models.

DeVries et al [2] revealed a major gap in the top-5 average accuracy of six
object recognition systems on images from high and low income households and
images from western and non-western geographies. Our goal is to reduce this
bias introduced into the systems because of the inherent nature of the
training data. Thus, the task is a simple classification problem, with inputs
being the images (resized to 224 $\times$ 224) from two datasets, detailed in
section 3, and the output being a class prediction. The task would use a
simple accuracy based metric for performance measurement, binned according to
incomes and geographies as done in [2].

We fine tune two popular image recognition models to run our experiments - VGG
[14] and ResNet [5], both pretrained on ImageNet. First, we test out different
techniques to tweak the fine tuning process - weighting the images by income,
under/over sampling the images to make the data distribution more uniform, and
implementing a focal loss [9] function to down-weight the inliers (easy
examples) and train on a sparse set of hard examples. We then try Adverserial
Discriminative Domain Adaptation (ADDA) [17] to observe if Domain Adaptation
is effective in solving the problem at hand.

##  2 Related Work

Our problem setting has been well explored in the analysis by DeVries et al
[2], which analyzes the performance of six object recognition systems on the
geographically diverse Dollar Street image dataset [1], revealing a major gap
in the performance of these systems on images from high and low income
households and images from western and non-western geographies. The Dollar
Street dataset [1] is a more geographically diverse dataset when compared to
other commonly used image datasets in object recognition. Qualitative analyses
suggest that there are two primary reasons behind the disparity in performance
across income groups: (1) Visual appearance difference within an object class
and (2) Items appearing in different contexts. The authors concluded that
there is a need to make object-recognition systems robust across different
geographies which motivated our work in this project [13].

If we view the problem at hand under the lens of unsupervised domain
adaptation, we can leverage the excellent performance of the models on the
high income groups to improve the performance on the low income groups [12].
There has been extensive work in the field of unsupervised visual domain
adaptation. One class of approaches involve the use of domain adversarial
objectives whereby a domain classifier is trained to distinguish between the
source and target representations while the domain representation is learned
so as to maximize the error of the domain classifier. The representation is
optimized using the standard minimax objective [4], or the inverted label
objective [17] etc. In this work, we mainly focus on Adversarial
Discriminative Domain Adaptation by Tzeng et al[17] who use adversarial
training to train a target encoder capable of encoding images from the target
domain into the same feature space as that of the source images [16].

We note that there exist many other approaches to domain adaptation notably
including a class of approaches which try to learn to convert images from the
target domain into the style of the source domain or vice-versa and then use
them for classification [15]. These approaches include works like CycleGANs
where the authors combine the standard adversarial loss terms with a cycle-
consistency loss term and achieve compelling image-image translation
results.[19]. While CycleGAN was not developed for thee purpose of domain
adaptation, it gave birth to approaches like CycADA [6] where the authors use
a slightly modified objective to achieve unsupervised domain adaptation.

##  3 Dataset and Features

The two datasets we use are The Dollar Street ImageDataset [1] and ImageNet
[3]. We also obtain metadata information about the images including the
geographic location and income levels.

###  3.1 Dollar Street Image Dataset

The Dollar Street Image Dataset is a collection of $\sim$30000 images taken
from over 264 homes in 50 countries. These images belong to 135 classes based
on household function and they come along with the location of the image and
the income level of the family, adjusted for purchasing power parity.

The challenge associated with obtaining these images is that there was no
public API exposed for trivial image collection. As a result, we had to
generate the static html for each of the categorical pages on the website, and
then scrape it to get the image url, the location, and the income level. We
skip the image urls that gave no response and combine some of the classes
which are semantically similar and have few independent samples, to give a
final list of 131 classes.

###  3.2 ImageNet

ImageNet is a large scale image database developed for advancing object
recognition models. Organized according to the WordNet [11] hierarchy,
ImageNet contains over 14 million hand annotated images spanning more than
20000 categories.

The only images we are interested in are those with geographic location
information. These are the images collected from Flickr, which account for
$\sim$10-20% of the entire corpus. Not all the images from Flickr have the
location metadata associated with them. Thus, as a preprocessing step, we use
the Flickr API to filter images with this metadata available. Because of time
constraints, we ran the image collection script for 2 days and were able to
obtain 50249 images encompassing 596 classes. This became the core dataset for
our experiments with ImageNet. Fig. 1 shows the geographical distribution of
the images collected. As we suspected, most of the images are obtained from
continents with high income level, such as North America and Europe, while
there are few image from continents like Africa and Asia.

Once we had the location information, the next step was to convert these to
income levels. For this, we decided to use income levels based on the
continent of origin for each image. We used the latitude and longitude of each
image to get the continent where it was from and mapped it to the income level
using Table 1, obtained from Wikipedia [18]. Antartica is not included in the
list of continents since its GDP per capita information was not available.
This is a very crude mapping for income levels given the extent of the
continents, but it does provide us with a ballpark figure.

To the best of our knowledge, there is no publically available dataset which
maps ImageNet images to location and income like we do here. Thus, this
dataset can be a contribution in itself.

Figure 1: Location Distribution for ImageNet Continent | GDP Per Capita (US $)
---|---
Oceania | 53,220
North America | 49,240
Europe | 29,410
South America | 8,560
Asia | 7,350
Africa | 1,930
Table 1: GDP Per Capita (Nominal) by Continent

##  4 Methods

Our approach is to first observe the extent of income and location biases in
popular objection recognition models, VGG [14] and ResNet [5], pretrained on
ImageNet. We then propose three methods: Weighted Loss, Sampling, and Focal
Loss for the task of mitigating this bias and achieving fairer results. The
same training methodology and fine-tuning architecture is used for both the
Dollar Street and the ImageNet dataset. Additionally, we also explore the
Adversarial Discriminative Domain Adaptation [17] model as our fourth method
and share our results.

###  4.1 Original Models

To see the performance of the original models to improve upon, we fine-tune
the VGG16 and ResNet-18 models (pretrained on ImageNet dataset) on the Dollar
Street and ImageNet datasets. This is done by freezing the weights of all
layers of the models except for the last one, which we replace with our own
custom classifier. The classifier has two fully connected layers with 256
neurons, ReLU activation, and a dropout layer with a dropout probability of
0.3, followed by a softmax output. The models are trained using negative log
likelihood loss, Adam optimizer with default hyperparameters, and a batch size
of 128. The default learning rate of 1e-3 was chosen after an empirical
analysis over the learning rates of 1e-2, 1e-3, and 1e-4.

###  4.2 Weighted Loss

Our first method for building a geography agnostic model entails a simple
income-specific re-weighting of the negative log likelihood loss. During
training, we take a batch of images and do a forward pass through a VGG16 pre-
trained model for the Dollar Street dataset and a ResNet-18 pre-trained model
for the ImageNet dataset as defined in Section 4.1. We obtain loss for each
training image of the batch and divide it by the income of that training
image. For normalization, we also multiply this loss with the mean income of
the training batch. Post this, we sum up the individual losses to get a single
training loss for the batch and do a backward pass. We outline this more
formally through Eq. 1.

$\displaystyle\mathcal{L}_{batch}=mean\\_batch\\_income*\sum_{i=1}^{B}\frac{loss_{i}}{income_{i}}$
(1)

Here, $\mathcal{L}_{batch}$ is the weighted batch loss, and $B$ is the batch
size. The intuition behind loss re-weighting is to penalize low-income images
more so that during training, the classifier learns to classify them better as
against the case where there was no re-weighting/penalization.

###  4.3 Sampling

While conducting exploratory data analysis, we observed that the income
distribution of training images is highly non-uniform. The consequence of the
skewed distribution is the inferior performance of most of the image-
classification models which have been pre-trained on high-income images. Our
second approach targets this problem before the training phase itself
(contrary to the method outlined in Section 4.2 where we tweak the loss during
training). We first divide the training images based on their incomes into
fix-sized income bins. We then fix an image size threshold of 5000 images and
sample (over and under) images from each bin. Specifically, we over sample
with replacement and under sample without replacement. We sample images such
that the number of images for each income bin is equal to the fixed image size
threshold. Doing this will make the income distribution of the training images
more uniform which will ensure the model to not be biased toward a particular
income group. Post this, we run our original pipeline of image classification
as outlined in Section 4.1.

###  4.4 Focal Loss

Class imbalance is a very common problem observed across various datasets
which represent real-life scenarios. By definition, class imbalance means that
we have an uneven distribution of training samples across different classes.
This leads the classification model to give superior results for the majority
class(es) and inferior results for the minority class(es). This is primarily
because classification models encompassing neural architectures tend to be
biased towards the class which is shown to them more often as their weights
gets optimized with respect to them more [8].

In our problem’s context, we have a skewed distribution of training images
across the income buckets. This leads to the disparity between the low and
high income procured images as seen in Fig. 3 and 4. To tackle this and make
the accuracy more uniform across various income buckets, we implemented focal
loss [9] which penalizes easily classified examples more as compared to the
difficult examples. The notion of ’penalize’ is however, unique in this
context. We penalize the easily classified examples by making their
contribution to the loss as minimal as possible. Specifically, if there is
some example belonging to a particular income bucket (high-income in our case)
which is very well classified (probability $>>$ 0.5), then we know it will
have a very small loss. However, in a class-imbalanced dataset such as ours,
there will be a lot of such examples from a particular income bucket that have
small individual loss but when added up, contribute significantly to the final
loss. Therefore, to avoid the network being biased to easily classified
samples, we multiply their probabilities with an expression involving their
softmax normalized scores, thereby diminishing their losses. Formally, we
tweak the cross-entropy loss function of a particular sample having softmax
score $p_{t}$ as:

$\displaystyle\mathcal{F}L(p_{t})=-(1-p_{t})^{\gamma}log(p_{t})$ (2)

In the above equation, notice that $-log(p_{t})$ is the original cross-entropy
loss equation where $p_{t}$ is the softmax score. Here $\gamma$ is a
hyperparameter which adjusts the rate at which easy examples are downweighted.

###  4.5 ADDA

Our third baseline is based on domain adaptation and uses a slightly modified
version of the ADDA model [17]. We split the Dollar street dataset [1] into
the source domain which consists of images with income level $>\$600$ and the
target domain which consists of low income images with income level $<=\$600$.
The training flow can be best understood from Fig. 2 and consists of the
following three steps:

  * •

A ResNet-18 model pretrained on ImageNet is used as the source encoder and is
finetuned along with the source classifier on the source domain images.

  * •

In the adversarial training step, we use a target encoder with the same
architecture as the source encoder as the Generator, and a 3 layer FFN as the
Discriminator, while holding the source encoder constant. The discriminator’s
task is to distinguish between the real and fake features from the 2 encoders
and the generator’s task is to encode the target images into a feature space
which is indistinguishable from the feature space of the source encoder.

  * •

Finally we test the trained target encoder on the target domain images. The
original model simply uses the classifier learned in the first phase to
classify the encoded images. Since we have the labels of the target domain, we
will fine-tune the classifier on the target domain images as well.

Figure 2: ADDA training procedure. Image taken from [17]

##  5 Experiments and Results

In this section, we describe and discuss the results of the experiments run
with the techniques mentioned in Section 4 on the Dollar Street and ImageNet
datasets.

###  5.1 Dollar Street Dataset

Table 2 shows the performance of different models on the Dollar Street
dataset. For ADDA, ResNet-18 seems to perform better. Fig. 3 shows shows the
accuracy as a moving average over the preceding ten income buckets as a
function of the income levels, divided into buckets of size $300, on the
original model and the four methods mentioned in Section 4. Table 3 shows the
top-5 accuracy of the ADDA source encoder on the Dollar Street dataset. Of all
the models tested, it seems like the VGG16 model with focal loss ($\gamma=5$)
works the best. It is able to flatten out the accuracy curve across income
levels to a reasonable extent, thereby reducing the inherent income-based bias
in the pre-trained model.

| VGG16 | ResNet-18
---|---|---
Model |  Train |  Val |  Train |  Val
Original | 83.28% | 81.55% | 84.07% | 80.56%
Weighted Loss | 77.71 % | 75.64 % | 80.23% | 73.41%
Sampling | 96.05 % | 77.06% | 93.88% | 75.43%
Focal Loss, $\gamma$=2 | 88.25% | 81.59% | 85.13% | 79.15%
Focal Loss, $\gamma$=5 | 87.83% | 80.50% | 83.34% | 79.86%
Focal Loss, $\gamma$=7 | 87.81% | 81.28% | 86.75% | 79.89%
Table 2: Top-5 Accuracy on Dollar Street Dataset | VGG16 | ResNet-18
---|---|---
Model |  Train |  Val |  Train |  Val
Trained on src Eval on src | 88.27% | 84.38% | 90.12% | 86.37%
Trained on tgt Eval on tgt | 76.22% | 72.24% | 79.26% | 74.35%
Trained on src Eval on tgt | 88.27% | 62.28% | 90.12% | 63.37%
Table 3: Top-5 Accuracy of ADDA Source Encoder on both domains. Figure 3:
Top-5 Accuracy on Dollar Street v/s Income Level (VGG16)

####  5.1.1 Original Models

Considering the whole dataset, the models perform well, as shown in Table 2.
However, the accuracy varies a lot based on the income group of the image. The
blue curve in Fig. 3 shows the accuracy of the original VGG16 model. It is
clear that the accuracy of the model increases as the income levels increase,
and that there is a substantial gap in the performance of the model on low-
income and high-income groups. Our goal would be to make this curve as flat as
possible to ensure unbiased performance.

####  5.1.2 Weighted Loss

As show in Table 2, weighted loss baseline has an overall train and validation
accuracy lower than the original model, however, as shown from Fig. 3, it is
able to reduce the accuracy deviation. For the original model, there is an
increasing trend observed for accuracy as we go from lower-income to higher-
income images. Specifically, the accuracy ranges from 83% to 90 %. However,
with a weighted-loss function, this trend is subdued and we achieve a smaller
range through which the accuracy is distributed. This shows that loss re-
weighting helps to make the model more robust across different income groups.

####  5.1.3 Sampling

Sampling results in an increase in the overall training dataset. Since, we
don’t perform sampling over the test set, the ratio of test set images to
train set images further reduces. This results in overfitting as now we have a
highly augmented train set which leads the model to learn even better on it.
The expected large gap between the train and validation accuracy is even seen
in Table 2. From Fig. 3, we observe that the sampling curve closely follows
the original curve till income level $5000. Post that, the sampling curve
drops which is a good sign as the accuracy disparity between high and low
income groups reduces. Hence, even with sampling, we are able to reduce the
accuracy deviation across different income groups, albeit not perfectly.

####  5.1.4 Focal Loss

Replacing the cross-entropy loss with focal loss leads to some interesting
results too. Quantitatively, for VGG16, validation accuracy of the original
model follidation accuracy of focal loss implemented models. We still see some
overfitting in the VGG16 models which could be caused by the focal loss
function. This is because, although we hope to tackle the class imbalance
problem through our newly implemented focal loss, we have not taken into
consideration the scenario of class imbalance (of a slightly different
distribution) existing in the validation set. Hence, while training, our model
parameters are optimized to be robust across the class distribution of the
train set, but might perform worse on the validation set. In Fig. 3, focal
loss with $\gamma=5$ seems to perform the best across all the models. It gives
us accuracy numbers closer to the original model and also reduces the accuracy
deviation across different income groups. It limits the accuracy numbers
between 82.5% and 87.5% while in the original model, it is between 82.5% and
90%.Initially, we see a downward trend in the accuracy as we increase the
income which then picks up later. However, $\gamma=5$ and $\gamma=7$ give
inferior results and increase this disparity even further. On the whole, focal
loss with $\gamma=5$ gives accuracy numbers at par with the original model
while reducing the accuracy disparity across income groups.

####  5.1.5 ADDA

Preliminary experiments with ADDA are meant to establish a clear domain shift
between high income and low income images. The results can be seen in Table 3
where we can see that a source encoder fine-tuned on the source domain images
achieves a validation accuracy of around $87\%$ (on ResNet-18) on the source
domain images but if we try to finetune the encoder on low income images (i.e.
the target domain), we can only achieve validation accuracy of around $74\%$
(on ResNet-18) on the low income images. Also, we see that if we use an
encoder trained on the source domain and evaluate it on the target domain, we
get a mere $63\%$ validation accuracy (on Resnet-18). Thus, there is a huge
domain shift between low income and high income images.

The experimental results were not as good as expected. They seem to suggest
that the domain shift is too large for the model to adapt to leading to the
target encoder not being able to learn meaningful representations of the
target domain images.

###  5.2 ImageNet

ResNet has been quantitatively proven to perform better than VGG16 on images
from ImageNet, based on its win in ILSVRC 2015. Thus, we use ResNet-18 as out
pre-trained model to perform experiments on ImageNet. Table 4 shows the
performance of ResNet-18 on the ImageNet dataset. The techniques tested here
are the ones which performed well on the Dollar Street Dataset. Fig. 4 shows
the accuracy over the six different income levels corresponding to the six
continents. The graph is not as smooth since we have a highly discretized
income space. The outcome here does not seem to be as promising as the one
from the Dollar Street dataset. However, the model with focal loss
($\gamma=5$) seems to help mitigate the difference in accuracies to a certain
extent.

| ResNet-18
---|---
Model |  Train |  Val
Original | 86.66% | 82%
Weighted Loss | 84.51% | 81.32 %
Focal Loss, $\gamma$=2 | 84.43% | 81.4%
Focal Loss, $\gamma$=5 | 87.52% | 81.17%
Table 4: Top-5 Accuracy on ImageNet Dataset Figure 4: Top-5 Accuracy on
ImageNet v/s Income Level (ResNet-18)

####  5.2.1 Original Models

The model performs well in terms of accuracy over the entire dataset, as seen
in Table 4. However, as is the case with the dollar street dataset, there is
significant variation in the accuracy based on the income level of the
location at which the image was taken. Although not as clear as the dollar
street dataset, it looks like the accuracy is higher for images from high
income level continents, with the highest accuracy being for Europe. The
lowest income continent, Africa, seems to have a high accuracy, but that might
be because of the high imbalance in the dataset - there are a lot fewer images
from Africa than from the other continents. Again, our goal here is to make
this curve as flat as possible.

####  5.2.2 Weighted Loss

In Table 4, the orange line shows the variation of the model with weighted
loss with income levels. It seems like this model actually performs worse than
the original model; the gap in the accuracies between the low and the high
incomes is even larger. This can be because of the way the income reweighting
is implemented - low income images are penalized more than high income images.
This makes the model focus more on getting the lower income images right,
which is evident from the fact that the accuracy increases for the images from
lower income levels. However, as a result of this weighting, high income
images are penalized less and their accuracy drops significantly. As a result,
there is a significant disparity in accuracy observed between the high and low
income levels.

####  5.2.3 Focal Loss

In the models using focal loss, shown by the green and the red lines in Fig.
4, the model with $\gamma$ = 5 seems to have better results than the income
reweighted loss. For $\gamma=2$, the model seems to perform worse than the
original model, with a big gap between the accuracies at the low and high
income levels. This can be because this value of $\gamma$ doesn’t focus on the
difficult examples and the easy examples still contribute to most of the
model’s loss.

However, $\gamma=5$ seems to present some promising results, although they are
not as good as expected. Overall, the accuracy seems to be lower than the
original model, but the accuracies for the lowest income level and the income
levels in the middle does decrease, resulting in a smaller variance in the
accuracy across all the income levels. This indicates that the model has
started focusing on the images which are difficult to classify (presumably the
images from the lower range of income levels), and these are the images that
guide the loss function for most of the training procedure.

##  6 Conclusion

In this project, we reveal the inherent bias in pretrained models like VGG-16
and Resnet-18 leading to huge gaps in performance between high income and low
income groups on Dollar Street and Imagenet datasets. We then apply techniques
like loss reweighting, sampling, focal loss and explore domain adaptation
techniques like ADDA for making these models fairer. We observe that our
models work better on Dollar Street than ImageNet which however did seem to
give decent results with focal loss with gamma = 5. We explore ADDA and
conclude that the domain shift between high and low income groups is too huge
to adapt to. For future work, we can have better income information for
Imagenet images and also explore more eadvanced domain adaptation techniques
like CycADA.

##  7 Contributions and Acknowledgements

All team members contributed equally to the project and Burak Uzkent(SAIL)
mentored us through the quarter.

## References

  * [1] https://www.gapminder.org/dollar-street.
  * [2] Terrance de Vries, Ishan Misra, Changhan Wang, and Laurens van der Maaten.  Does object recognition work for everyone?  In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops, pages 52–59, 2019.
  * [3] J. Deng, W. Dong, R. Socher, L. Li, Kai Li, and Li Fei-Fei.  Imagenet: A large-scale hierarchical image database.  In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pages 248–255, 2009.
  * [4] Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario Marchand, and Victor Lempitsky.  Domain-adversarial training of neural networks.  The Journal of Machine Learning Research, 17(1):2096–2030, 2016\.
  * [5] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun.  Deep residual learning for image recognition.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
  * [6] Judy Hoffman, Eric Tzeng, Taesung Park, Jun-Yan Zhu, Phillip Isola, Kate Saenko, Alexei A Efros, and Trevor Darrell.  Cycada: Cycle-consistent adversarial domain adaptation.  arXiv preprint arXiv:1711.03213, 2017.
  * [7] Ivan Krasin, Tom Duerig, Neil Alldrin, Vittorio Ferrari, Sami Abu-El-Haija, Alina Kuznetsova, Hassan Rom, Jasper Uijlings, Stefan Popov, Andreas Veit, et al.  Openimages: A public dataset for large-scale multi-label and multi-class image classification.  Dataset available from https://github. com/openimages, 2(3):18, 2017\.
  * [8] SDGV Akanksha Kumari and Shreya Singh.  Parallelization of alphabeta pruning algorithm for enhancing the two player games.  Int. J. Advances Electronics Comput. Sci, 4:74–81, 2017.
  * [9] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár.  Focal loss for dense object detection.  In Proceedings of the IEEE international conference on computer vision, pages 2980–2988, 2017.
  * [10] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick.  Microsoft coco: Common objects in context.  In European conference on computer vision, pages 740–755. Springer, 2014.
  * [11] George A Miller.  WordNet: An electronic lexical database.  MIT press, 1998.
  * [12] G Mohammed Abdulla, Shreya Singh, and Sumit Borar.  Shop your right size: A system for recommending sizes for fashion products.  In Companion Proceedings of The 2019 World Wide Web Conference, WWW ’19, page 327–334, New York, NY, USA, 2019. Association for Computing Machinery.
  * [13] Abraham Gerard Sebastian, Shreya Singh, P. B. T. Manikanta, T. S. Ashwin, and G. Ram Mohana Reddy.  Multimodal group activity state detection for classroom response system using convolutional neural networks.  In Pankaj Kumar Sa, Sambit Bakshi, Ioannis K. Hatzilygeroudis, and Manmath Narayan Sahoo, editors, Recent Findings in Intelligent Computing Techniques, pages 245–251, Singapore, 2019. Springer Singapore.
  * [14] Karen Simonyan and Andrew Zisserman.  Very deep convolutional networks for large-scale image recognition.  arXiv preprint arXiv:1409.1556, 2014.
  * [15] Loveperteek Singh, Shreya Singh, Sagar Arora, and Sumit Borar.  One embedding to do them all.  arXiv preprint arXiv:1906.12120, 2019.
  * [16] Shreya Singh, G Mohammed Abdulla, Sumit Borar, and Sagar Arora.  Footwear size recommendation system.  arXiv preprint arXiv:1806.11423, 2018.
  * [17] Eric Tzeng, Judy Hoffman, Kate Saenko, and Trevor Darrell.  Adversarial discriminative domain adaptation.  In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 7167–7176, 2017.
  * [18] Wikipedia contributors.  List of continents by gdp (nominal) — Wikipedia, the free encyclopedia, 2020.  [Online; accessed 7-June-2020].
  * [19] Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros.  Unpaired image-to-image translation using cycle-consistent adversarial networks.  In Proceedings of the IEEE international conference on computer vision, pages 2223–2232, 2017.