reproducing MMDT@ICML2013

[Domain Adaptation Project](https://www.eecs.berkeley.edu/~jhoffman/domainadapt/)のMax-margin Domain Transformations (MMDT)の再現方法．

- J. Hoffman, E. Rodner, J. Donahue, K. Saenko, and T. Darrell, "Efficient Learning of Domain Invariant Image Representations", ICLR2013.

# Build

```sh:

wget http://vision.cs.uml.edu/code/DomainTransformsECCV10_v1.tar.gz
tar xzvf DomainTransformsECCV10_v1.tar.gz 
wget http://www-scf.usc.edu/~boqinggo/domain_adaptation/GFK_v1.zip
unzip GFK_v1.zip 
wget http://www.csie.ntu.edu.tw/%7Ecjlin/libsvmtools/weights/liblinear-weights-2.01.zip
unzip liblinear-weights-2.01.zip 


git clone https://github.com/jhoffman/MaxMarginDomainTransforms.git
cd MaxMarginDomainTransforms
patch -p0 << EOF
--- demo.m.orig	2016-03-25 13:37:47.000000000 +0900
+++ demo.m	2016-03-25 13:39:07.000000000 +0900
@@ -47,7 +47,7 @@
     tstart = tic;
     [model_mmdt, W] = TrainMmdt(labels.train, data.train, param);
     telapsed(i) = toc(tstart);
-    [pl, acc] = predict(labels.test.target', ...
+    [pl, acc, ~] = predict(labels.test.target', ...
         [sparse(data.test.target), ones(length(labels.test.target),1)], ...
         model_mmdt);
     accuracy(i) = acc(1);
EOF
patch -p0 << EOF
--- demo_allSplits.m.orig	2016-03-25 13:37:47.000000000 +0900
+++ demo_allSplits.m	2016-03-25 12:53:55.000000000 +0900
@@ -53,7 +53,7 @@
             tstart = tic;
             [model, W] = TrainMmdt(labels.train, data.train, param);
             telapsed(i) = toc(tstart);
-            [pl, acc] = predict(labels.test.target', ...
+            [pl, acc, ~] = predict(labels.test.target', ...
                 [sparse(data.test.target), ones(length(labels.test.target),1)], ...
                 model);
             accuracy(i) = acc(1);
EOF
patch -p0 << EOF
--- AddDependencies.m.org	2016-03-25 13:56:27.000000000 +0900
+++ AddDependencies.m	2016-03-25 13:55:40.000000000 +0900
@@ -1,6 +1,6 @@
 % add dependencies
-LIBLINEAR_WEIGHTS_PATH = '../../dev/mmdt_liblinear/liblinear/matlab/';
-SAENKO_ECCV10_RELEASE = '../DomainTransformsECCV10';
+LIBLINEAR_WEIGHTS_PATH = '../liblinear-weights-2.01/matlab/';
+SAENKO_ECCV10_RELEASE = '../DomainTransformsECCV10/';
 
 addpath(LIBLINEAR_WEIGHTS_PATH);
 addpath(SAENKO_ECCV10_RELEASE);
EOF
patch -p0 << EOF
--- Config.m.org	2016-03-25 13:57:45.000000000 +0900
+++ Config.m	2016-03-25 13:57:19.000000000 +0900
@@ -14,7 +14,7 @@
 
 %%%%%                      PARAMETERS TO EDIT                       %%%%%%
 % Directory containing the data 
-param.DATA_DIR = '~/code/dev/OfficeExperiments/datacodeofthegeodesicflowkernel/';
+param.DATA_DIR = '../ToRelease_GFK/data/';
 
 % Choose the experiment type
 param.held_out_categories = false; 
EOF

# if you don't have Statistics toolbox,
wget https://raw.githubusercontent.com/skaae/rbm_toolbox/master/util/zscore.m
patch -p0 << EOF
--- zscore.m.org	2016-03-25 14:06:15.000000000 +0900
+++ zscore.m	2016-03-25 14:06:32.000000000 +0900
@@ -1,4 +1,4 @@
-function [x, mu, sigma] = zscore(x)
+function [x, mu, sigma] = zscore(x,~)
     mu=mean(x);	
     sigma=max(std(x),eps);
 	x=bsxfun(@minus,x,mu);
EOF
wget http://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/47180/versions/1/download/zip -O princomp.zip
unzip princomp.zip princomp.m
```

そしてMATLABを起動して，`liblinear-weights-2.01/matlab/`に移動して，MATLABコマンドウィンドウで

```matlabsession:実行
make
```
する．

（mexにパスが通っていれば，シェルでmakeしてもよい）


# Run

`MaxMarginDomainTransforms/`で

```matlabsession:実行
demo_allScript
```

を実行．

```matlabsession:実行結果
amazon -> webcam:  65.04 +/-   1.3
amazon -> dslr:  54.57 +/-   1.0
amazon -> caltech:  39.96 +/-   0.5
webcam -> amazon:  50.55 +/-   0.8
webcam -> dslr:  62.52 +/-   1.1
webcam -> caltech:  34.67 +/-   0.8
dslr -> amazon:  50.20 +/-   0.8
dslr -> webcam:  73.75 +/-   0.8
dslr -> caltech:  35.44 +/-   0.7
caltech -> amazon:  50.89 +/-   0.8
caltech -> webcam:  62.55 +/-   1.1
caltech -> dslr:  53.31 +/-   1.0


 Mean acc all:  52.79
```