README.md 1.9 KB
Newer Older
Neal Wu's avatar
Neal Wu committed
1
# Domain Separation Networks
2

Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

## Introduction
This code is the code used for the "Domain Separation Networks" paper
by Bousmalis K., Trigeorgis G., et al. which was presented at NIPS 2016. The
paper can be found here: https://arxiv.org/abs/1608.06019

## Contact
This code was open-sourced by Konstantinos Bousmalis (konstantinos@google.com, github:bousmalis)

## Installation
You will need to have the following installed on your machine before trying out the DSN code.

*  Tensorflow: https://www.tensorflow.org/install/
*  Bazel: https://bazel.build/

## Important Note
Although we are making the code available, you are only able to use the MNIST
provider for now. We will soon provide a script to download and convert MNIST-M
as well. Check back here in a few weeks or wait for a relevant announcement from
Twitter @bousmalis.

## Running the code for adapting MNIST to MNIST-M
In order to run the MNIST to MNIST-M experiments with DANNs and/or DANNs with
domain separation (DSNs) you will need to set the directory you used to download
Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
27
MNIST and MNIST-M:\
28
29

```
Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
30
$ export DSN_DATA_DIR=/your/dir
31
```
Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
32
33
34

Then you need to build the binaries with Bazel:

35
```
Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
36
$ bazel build -c opt domain_adaptation/domain_separation/...
37
```
Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
38
39
40

You can then train with the following command:

41
```
Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
42
43
44
45
46
47
48
49
50
51
52
53
54
$ ./bazel-bin/domain_adaptation/domain_separation/dsn_train  \
      --similarity_loss=dann_loss  \
      --basic_tower=dann_mnist  \
      --source_dataset=mnist  \
      --target_dataset=mnist_m  \
      --learning_rate=0.0117249  \
      --gamma_weight=0.251175  \
      --weight_decay=1e-6  \
      --layers_to_regularize=fc3  \
      --nouse_separation  \
      --master=""  \
      --dataset_dir=${DSN_DATA_DIR}  \
      -v --use_logging
55
56
```

Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
57

58
Evaluation can be invoked with the following command:
Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
59

60
```
Konstantinos Bousmalis's avatar
Konstantinos Bousmalis committed
61
62
63
$ ./bazel-bin/domain_adaptation/domain_separation/dsn_eval  \
    -v --dataset mnist_m --split test --num_examples=9001  \
    --dataset_dir=${DSN_DATA_DIR}
64
```