Home

Awesome

DANN-PyTorch :fire:

PyTorch implementation of DANN (Domain-Adversarial Training of Neural Networks)

Unsupervised Domain Adaptation by Backpropagation</br> Yaroslav Ganin, Victor Lempitsky</br> In PMLR-2015

Domain-Adversarial Training of Neural Networks</br> Yaroslav Ganin et al.</br> In JMLR-2016

Getting started

Installation

Install library versions that are compatible with your environment.

git clone https://github.com/NaJaeMin92/pytorch-DANN.git
cd pytorch-DANN
conda create -n dann python=3.7
conda activate dann
pip install -r requirements.txt

Recommended configuration

python=3.7
pytorch=1.12.1
matplotlib=3.2.2
sklearn=1.0.2

Usages

Running the code below will execute both source-only and DANN training and testing:

python main.py
# You can adjust training settings in 'params.py', including batch size and the number of training epochs.

t-SNE (t-distributed Stochastic Neighbor Embedding)

Our code includes the functionality to visualize t-SNE, both before and after the process of domain adaptation using sklearn.manifold.

Experimental results

MNIST -> MNIST-M

MethodTest #1Test #2Test #3Test #4Test #5Avg.
Source Accuracy899898909861.2
Target Accuracy475654465351.2

DANN

MethodTest #1Test #2Test #3Test #4Test #5Avg.
Source Accuracy969697979696.4
Target Accuracy837880807879.8
Domain Accuracy606061646161.2