adapy

Library for domain adaptation


Keywords
domain, adaptation, tranfer, learning
License
MIT
Install
pip install adapy==0.8

Documentation

ADAPY

Build Status Python 3.4 Python 3.4

Adapy is an open-source code that contains a framework for implementing adversarial discriminative domain adaptation in tranfer learning.

Introduction

Given two datasets with the same label space such that exactly one of them is labelled -the source dataset- , we can retrieve the labels for the other -the target dataset- through the method of domain adaptation. If you are new with Adversarial Discriminative Domain Adaptation you could first have a look at Adversarial Nets.

Our goal is to create a strictly structured library to implement algorithms for domain adaptation.

Overview

Adversarial networks for domain adaptation can be broken down as follows: There are two “representer” networks MS and MT mapping the source and target domains respetively to a common latent space and a domain discriminator network D mapping the latent space to the interval. Additionally, there is a classifier network C that maps the output of MS to a distribution over the common label space. In the adaptation phase, MS and MT are trained so that D cannot discriminate between their outputs and so that C performs well on source data given input from MS. On the other hand, D is trained to distinguish the outputs of MS and MT. Under a suitable loss function, we can think of D(x)’s as measuring the likelihood that x was generated by MS. The aim is to reach an equillibrium (point of convergence) where D is identically 0.5 and where C performs well. This would imply that the distributions of MS(xs)xS∌P(XS) and MT(xt)xt∌P(XT) are identical (or rather indistinguishable by an adversary with the complexity of D) and that MS(x) is rich enough for TS. Because C provides a good model for P(Y|MS(XS)), by the domain adaptaition assumptions, it must also provide a good model for P(Y|MT(XT)). So provided we can construct our network topologies and objective functions so that the above equillibrium is reachable, we can solve the covariate shift problem. In fact, here we have assumed P(Y|MS(X))≈P(Y|MT(X)) which is reasonable if Mt≈Ms or if good transfer has occured.

Getting it

To download adapy, you can either fork this github repository or use Pypi via pip.

$ pip install adapy
Using it

Adapy was programmed to be initialized with a source representation model and use the same classifier that has been produced during the training part of source model.

$ from adapy import Adapy
Dependencies

Before use , need to be install :

  • Keras
  • Numpy
  • Tqdm
  • Imageio
  • Tensorflow