Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dot not merge! only used to difference between mhof_dev and mhof(fbopt) #884

Open
wants to merge 401 commits into
base: mhof
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
401 commits
Select commit Hold shift + click to select a range
518d919
fixed codacity
May 28, 2024
e947f67
fixed codacity
May 28, 2024
94a1819
Merge branch 'master' into mhof_dev_merge
May 28, 2024
5b28c73
Added the hyperparameter naming to parts of the models novel on this …
May 28, 2024
bc3c808
ci running, exiting with 0, removing prints
May 28, 2024
e6a6f3e
Merge branch 'mhof_dev_merge' into erm_hyper_init
May 28, 2024
5d2fb82
Fixed codacity
Jun 11, 2024
7124cc7
Fixed codacity
Jun 11, 2024
570e8a8
fixed codacity
Jun 11, 2024
5288432
Merge branch 'mhof_dev_merge' into erm_hyper_init
MatteoWohlrapp Jun 11, 2024
d2ac388
retrigger run
Jun 11, 2024
4f1347a
fixed codacity
Jun 11, 2024
6a81b4c
Merge branch 'erm_hyper_init' of https://github.com/marrlab/DomainLab…
Jun 11, 2024
f2fa952
fixed codacity
Jun 11, 2024
279f510
Added test for erm functions
Jun 11, 2024
f8f4f0e
Disabling line too long for argument
Jun 11, 2024
31f90fc
Saving initial model
Jun 25, 2024
5a99aa6
Renamed common benchmark file
Jun 25, 2024
88e383d
Specified pip version
Jun 25, 2024
c672a04
Specified pip version
Jun 25, 2024
13af9f0
Update pyproject.toml for version lower than 70 of setup tools
smilesun Jun 27, 2024
1220cc1
delete poetry lock
smilesun Jun 27, 2024
c546ae9
update requirments.txt using poetry
smilesun Jul 1, 2024
3b91f70
Update pyproject.toml
smilesun Jul 2, 2024
e67e212
Removed explicit pip version in ci, added comment about user starting…
Jul 2, 2024
c7caeb5
Merge branch 'mhof_dev_merge' into erm_hyper_init
MatteoWohlrapp Jul 2, 2024
faf7589
Merge pull request #821 from marrlab/benchmark_results_suffix
smilesun Jul 2, 2024
530999b
Merge branch 'erm_hyper_init' into erm_hyper_init_updated_irm
smilesun Jul 2, 2024
1198eeb
Corrected doc for gamma_reg, added docstring to call method in argpar…
Jul 2, 2024
d1ccf46
Update task_pacs_aug.py, update path of PACS
smilesun Jul 2, 2024
6acdfdd
Update pacs_fbopt_fishr_erm.yaml
smilesun Jul 2, 2024
d60a789
Update pacs_fbopt_fishr_erm.yaml
smilesun Jul 2, 2024
bc060ba
Merge branch 'master' into gamma_reg_collision
smilesun Jul 2, 2024
f9282b4
Merge branch 'master' into save-initial-model
smilesun Jul 2, 2024
976c25a
Update task_pacs_aug.py, fix codacy
smilesun Jul 2, 2024
97d9320
Update arg_parser.py, update documentation , remove diva gamma_reg
smilesun Jul 2, 2024
05d228b
Update doc_usage_cmd.md, remove diva gamma_reg in doc
smilesun Jul 2, 2024
5c0f6b1
Update doc_usage_cmd.md
smilesun Jul 2, 2024
5ff5fd3
merge commit
MatteoWohlrapp Jul 2, 2024
31ce1ec
fixed argparser syntax, renamed argument
MatteoWohlrapp Jul 2, 2024
6392ac5
Update vlcs_diva_mldg_dial.yaml
smilesun Jul 2, 2024
0d62919
Update test_hyperparameter_retrieval.py, comments in unit test
smilesun Jul 2, 2024
a99c9f5
Merge pull request #843 from marrlab/erm_hyper_init
smilesun Jul 2, 2024
bdf84c2
style
smilesun Jul 2, 2024
ca493e5
Merge pull request #806 from marrlab/gamma_reg_collision
smilesun Jul 2, 2024
6c8b9a6
Merge branch 'master' into save-initial-model
smilesun Jul 2, 2024
33ed1cb
Merge pull request #845 from marrlab/mhof_dev_merge
smilesun Jul 2, 2024
f90e655
Merge branch 'mhof_dev' into erm_hyper_init_updated_irm
smilesun Jul 5, 2024
8d6a356
use commandline to specify enviornemnt variable
smilesun Jul 5, 2024
8182f5b
{log_dir}
smilesun Jul 5, 2024
422aaa5
define resources in each rule
smilesun Jul 8, 2024
75d3aca
slurm custom dir works
smilesun Jul 11, 2024
eb445cb
Update benchmark.smk
smilesun Jul 11, 2024
bac7907
Update config.yaml
smilesun Jul 11, 2024
d72a8e4
update doc
smilesun Jul 11, 2024
344936b
Merge pull request #849 from marrlab/benchmark_slurm_log
smilesun Jul 11, 2024
e4a09bd
0.6.5 slrum logs custom dir
smilesun Jul 11, 2024
1aa3d20
let snakemake lmajor jog file be in benchmark directory
smilesun Jul 12, 2024
d23139d
Merge pull request #850 from marrlab/snakemake_log_in_benchmark_dir
smilesun Jul 12, 2024
a5e5391
Update run_benchmark_standalone.sh
smilesun Jul 12, 2024
99ed0f1
Update run_benchmark_standalone.sh
smilesun Jul 12, 2024
7225ea9
Merge branch 'master' into save-initial-model
smilesun Jul 12, 2024
892ed53
Merge pull request #851 from marrlab/yaml-file-copied-to-results-dir
smilesun Jul 12, 2024
7f7b410
Update config.yaml: outputFolderAsJobName
smilesun Jul 12, 2024
d996dd2
Merge pull request #852 from marrlab/outputFolderAsJobName
smilesun Jul 12, 2024
c2d0427
.
smilesun Jul 12, 2024
04d6464
Merge branch 'master' into jobname2
smilesun Jul 12, 2024
4d873e7
Merge pull request #853 from marrlab/jobname2
smilesun Jul 12, 2024
ee30859
Create slurm_status.sh
smilesun Jul 12, 2024
7d53d7e
chmod slurm_status
smilesun Jul 12, 2024
0578510
Merge branch 'master' into save-initial-model
smilesun Jul 12, 2024
d6e5091
.
smilesun Jul 12, 2024
3dfd3a4
Update ci.yml, rm -rf instead rm -r
smilesun Jul 12, 2024
bfc8f13
Update benchmark.smk
smilesun Jul 12, 2024
a9f358e
Update a_observer.py: rm str_msel since plays no rule
smilesun Jul 12, 2024
b673fbb
Update doc_benchmark.md
smilesun Jul 12, 2024
f4e6a0c
merge conflict
smilesun Jul 12, 2024
f1b413f
Merge branch 'mhof_dev' into erm_hyper_init_updated_irm
smilesun Jul 12, 2024
27505b9
Merge pull request #856 from marrlab/rm_str_msel
smilesun Jul 14, 2024
10cf584
Merge pull request #854 from marrlab/testout
smilesun Jul 14, 2024
3ca86ad
Update benchmark.smk
smilesun Jul 14, 2024
f2ec2d6
Merge branch 'master' into print-sampled-hyperparameters.csv
smilesun Jul 14, 2024
d90ffae
Merge branch 'master' into mhof_dev
smilesun Jul 14, 2024
888c1ef
Merge pull request #855 from marrlab/print-sampled-hyperparameters.csv
smilesun Jul 15, 2024
0605ffc
Merge branch 'master' into mhof_dev
smilesun Jul 15, 2024
4819a93
Merge branch 'master' into save-initial-model
smilesun Jul 15, 2024
1c683ba
Update pacs_fbopt_dial_diva.yaml
smilesun Jul 16, 2024
2a408ec
doc for IRM
smilesun Jul 18, 2024
9f73d67
simple expoential moving aveage
smilesun Jul 18, 2024
97112a2
move avarage rho set w.r.t. epoch
smilesun Jul 18, 2024
bbac2b5
rmove if
smilesun Jul 18, 2024
8e8827c
.
smilesun Jul 18, 2024
2e66bba
unit test move average
smilesun Jul 18, 2024
3d4a00b
add irm to doc
smilesun Jul 18, 2024
21361d8
.
smilesun Jul 18, 2024
8737551
.
smilesun Jul 18, 2024
fd118a6
.
smilesun Jul 18, 2024
4621dcc
Merge pull request #858 from marrlab/sma
smilesun Jul 18, 2024
dc7005a
Merge branch 'master' into mhof_dev
smilesun Jul 18, 2024
1a8c0fe
Merge branch 'master' into save-initial-model
smilesun Jul 18, 2024
10442ba
better yaml for dial_diva
smilesun Jul 18, 2024
1df808a
ma in index
smilesun Jul 20, 2024
6f5ce78
Merge branch 'master' into mhof_dev
smilesun Jul 20, 2024
1005760
estimate scale ratio at begin
smilesun Jul 24, 2024
209a137
ratio estimation done
smilesun Jul 25, 2024
ad6e7f4
reg over task ratio inserted
smilesun Jul 25, 2024
9cb3e09
.
smilesun Jul 25, 2024
b90c79a
fix divide by zero
smilesun Jul 25, 2024
87791c5
Merge branch 'master' into save-initial-model
smilesun Jul 25, 2024
a78d84e
Update train_ema.py
smilesun Jul 25, 2024
a5f0f07
fix bug in ema
smilesun Jul 25, 2024
e8c4973
Merge branch 'master' into save-initial-model
smilesun Jul 25, 2024
d7a4ed3
first version causal irl
smilesun Jul 25, 2024
2f3d6d8
Merge branch 'master' into scale_weight
smilesun Jul 25, 2024
c2ad38a
Update exp_main.py
smilesun Jul 25, 2024
c9242cd
Update exp_main.py
smilesun Jul 25, 2024
f5efc76
Update train_basic.py
smilesun Jul 25, 2024
1520907
Merge pull request #846 from marrlab/save-initial-model
smilesun Jul 25, 2024
2eda4e1
Merge branch 'master' into causalIRL
smilesun Jul 25, 2024
71809ec
Merge branch 'master' into scale_weight
smilesun Jul 25, 2024
55bba05
Update ci.yml, pytest config
smilesun Jul 25, 2024
aa53b31
torch no_grad for ratio calculation
smilesun Jul 25, 2024
bc4c4ed
remove torch_no_grad: dial, dann need grad
smilesun Jul 25, 2024
174799d
Merge branch 'master' into mhof_dev
smilesun Jul 25, 2024
f5a2a58
matteo change
smilesun Jul 25, 2024
d7365f4
codacy
smilesun Jul 25, 2024
15d776d
by default no ratio estimation
smilesun Jul 26, 2024
589c428
.
smilesun Jul 26, 2024
885fe0f
replicate irm loss to batch size
smilesun Jul 26, 2024
c599946
clean test msel oracle
smilesun Jul 26, 2024
a505707
.
smilesun Jul 26, 2024
8efecac
decrease batch size for msel_orcale test
smilesun Jul 26, 2024
235832a
split msel_oracle test
smilesun Jul 26, 2024
1feff92
Update test_msel_oracle.py
smilesun Jul 26, 2024
d012b94
Update test_msel_oracle.py
smilesun Jul 26, 2024
34975da
Update test_msel_oracle2.py
smilesun Jul 26, 2024
4301cd4
Merge pull request #863 from marrlab/scale_weight
smilesun Jul 26, 2024
151703a
Merge branch 'master' into erm_hyper_init
smilesun Jul 27, 2024
9c7dbd2
Merge branch 'master' into causalIRL
smilesun Jul 27, 2024
2c1cdc9
coverage
smilesun Aug 1, 2024
88fd530
Merge pull request #864 from marrlab/causalIRL
smilesun Aug 2, 2024
6f6169e
split examples into algo doc
smilesun Aug 6, 2024
1e2ff25
.
smilesun Aug 22, 2024
ea97541
Update ci_run_examples.sh
smilesun Sep 2, 2024
7733091
Update docIRM.md to check if CI fails
smilesun Sep 5, 2024
bb1500b
split hduva
smilesun Sep 5, 2024
f9bdbb1
coral is just cross domain MMD distance
smilesun Sep 5, 2024
b0983bf
Update ci_run_examples.sh, cat command from each markdown file
smilesun Sep 10, 2024
05e41fb
Update docIRM.md
smilesun Sep 10, 2024
0ff6ae7
Update docIRM.md
smilesun Sep 11, 2024
6b01a3a
Update docIRM.md, remove agas to see if it works
smilesun Sep 11, 2024
7494a61
Merge pull request #874 from marrlab/example
smilesun Sep 11, 2024
463f1a1
Merge branch 'master' into coral
smilesun Sep 11, 2024
47e0ce2
Merge branch 'master' into erm_hyper_init
smilesun Sep 11, 2024
3ede584
add test
smilesun Sep 16, 2024
e51b7b5
cross domain mmd
smilesun Sep 16, 2024
8fcbc12
fix invalid charater
smilesun Sep 16, 2024
9da2dee
Merge pull request #869 from marrlab/erm_hyper_init
smilesun Sep 16, 2024
c83d50a
Merge branch 'master' into coral
smilesun Sep 16, 2024
fbd47f5
Update train_coral.py
smilesun Sep 17, 2024
50a446d
.
smilesun Sep 17, 2024
cf6996f
sum mmd batch
smilesun Sep 17, 2024
2b2c29c
.
smilesun Sep 17, 2024
c078bc4
.
smilesun Sep 17, 2024
88ec169
.
smilesun Sep 17, 2024
50ce5a9
put all examples in doc_example.md into separate docs
smilesun Sep 17, 2024
5a164a9
.
smilesun Sep 17, 2024
c46205b
.
smilesun Sep 17, 2024
77b64d6
Merge pull request #875 from marrlab/coral
smilesun Sep 17, 2024
588fff9
Merge pull request #876 from marrlab/doc_example
smilesun Sep 17, 2024
580bd23
Merge branch 'master' into mhof_dev
smilesun Sep 17, 2024
206953b
.
smilesun Sep 17, 2024
9707673
Merge pull request #877 from marrlab/doc_coral_irl
smilesun Sep 18, 2024
d466b75
.
smilesun Sep 18, 2024
12c1073
0.7.0
smilesun Sep 18, 2024
93d59c8
fix typo in irm doc
smilesun Sep 19, 2024
c7cf554
fix doc IRL
smilesun Sep 27, 2024
4686aa4
Merge branch 'master' into mhof_dev
smilesun Oct 4, 2024
913873f
Merge branch 'mhof_dev' into erm_hyper_init_updated_irm
smilesun Oct 4, 2024
b2b204d
copy branch fbopt_vector_ki_gain to mhof_dev
smilesun Oct 4, 2024
0678950
rename yaml
smilesun Oct 5, 2024
9a01811
erm alone more hyper
smilesun Oct 5, 2024
9150621
Merge pull request #838 from marrlab/erm_hyper_init_updated_irm
smilesun Oct 5, 2024
ca9766e
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 5, 2024
cbdc505
Update aistat_irm_erm_mhof.yaml
smilesun Oct 6, 2024
731a144
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 6, 2024
144efba
Update aistat_irm_erm_mhof.yaml, fix grammar error
smilesun Oct 6, 2024
9e09396
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 6, 2024
68c1e36
Update sh_link_pacs_dataset.sh
smilesun Oct 6, 2024
b4ddafe
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 6, 2024
3a051fe
Update .gitignore, display slurm_errors,
smilesun Oct 6, 2024
d53c863
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 6, 2024
fe84b5b
Update and rename sh_list_job_via_slurm_id.sh to sh_list_job_via_run_…
smilesun Oct 8, 2024
e731f27
Merge branch 'master' into mhof_dev
smilesun Oct 8, 2024
f15478c
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 8, 2024
1be1634
causalirl yaml
smilesun Oct 8, 2024
121ca55
.
smilesun Oct 8, 2024
6626475
use self.decoratee instead of self.model
smilesun Oct 8, 2024
d5d3a0b
cmd script to test mhof irm
smilesun Oct 8, 2024
e6c368b
script to test mhof_irm
smilesun Oct 8, 2024
6701cbf
enable grad for irm inside torch.no_grad for mhof
smilesun Oct 9, 2024
888d714
filter out zero reg loss in abstract trainer
smilesun Oct 9, 2024
64bcc9c
trainer behaves like model, now decoratte's cal_loss has to be changed
smilesun Oct 9, 2024
22f343c
overwrite multiplier from scheduler(default static scheduler then no …
smilesun Oct 9, 2024
23607fb
per domain irm to separate file
smilesun Oct 9, 2024
28bdfa9
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 9, 2024
63ad47b
dial mhof yaml
smilesun Oct 9, 2024
8ba7e11
number of bathces to estimate ratio
smilesun Oct 9, 2024
6073403
Update aistat_irm_erm_only.yaml
smilesun Oct 9, 2024
8bd1163
Update aistat_irm_erm_mhof.yaml
smilesun Oct 9, 2024
7667cbc
.
smilesun Oct 9, 2024
5eefec0
fix #issue 881, nb4reg_over_task_ratio is 0 cause error
smilesun Oct 10, 2024
5800ef1
Merge branch 'master' into mhof_dev
smilesun Oct 10, 2024
795478f
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 10, 2024
b64e5d0
Update aistat_irm_erm_only.yaml
smilesun Oct 10, 2024
0033cd2
mv scripts from root folder to scripts folder
smilesun Oct 10, 2024
88861ce
Merge branch 'master' into mhof_dev
smilesun Oct 10, 2024
6433f58
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 10, 2024
80dcfe4
unit test number batches for estimate loss raiot
smilesun Oct 10, 2024
d9eb780
.
smilesun Oct 10, 2024
8ea9aa2
Merge pull request #883 from marrlab/num_batches_est_ratio
smilesun Oct 10, 2024
62183bc
Merge branch 'master' into mhof_dev
smilesun Oct 10, 2024
6f5bac1
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 10, 2024
ba68e27
fix num_batches for loss ratio estimate
smilesun Oct 10, 2024
c09879d
.
smilesun Oct 10, 2024
394cdd6
add back missing @property due to text insert
smilesun Oct 10, 2024
401e978
Merge branch 'mhof_dev' into mhof_dev_vector_ki_gain
smilesun Oct 10, 2024
5585b4a
use correct hyper range
smilesun Oct 10, 2024
d176e1a
Update aistat_irm_erm_mhof.yaml
smilesun Oct 10, 2024
3a4226e
add unit test
smilesun Oct 10, 2024
011cccb
Update aistat_irm_erm_mhof.yaml
smilesun Oct 10, 2024
ae03219
Update and rename pacs_fbopt_dial_diva.yaml to aistat_pacs_mhof_dial_…
smilesun Oct 10, 2024
3166eb2
dial
smilesun Oct 10, 2024
d8cee2d
fix partially issue #777
smilesun Oct 11, 2024
9884640
detailed doc for mhof args, change str args to boolean, fix issue #777
smilesun Oct 11, 2024
cd15915
new irm yaml file
smilesun Oct 11, 2024
273422b
.
smilesun Oct 11, 2024
dbbda55
take square of irm loss, copy reg loss from decoratee to fbopt
smilesun Oct 11, 2024
1cb2428
.
smilesun Oct 11, 2024
155f0df
.
smilesun Oct 11, 2024
c41e92b
.
smilesun Oct 11, 2024
b8731cb
Milestone: feedforward works now with trainers
smilesun Oct 13, 2024
f4e4773
yaml for feedforward
smilesun Oct 13, 2024
e3ed8c6
tr_with_init_mu
smilesun Oct 15, 2024
e38fa75
doc
smilesun Oct 15, 2024
044e3cc
.
smilesun Oct 15, 2024
aea6e90
no ma for setpoint
smilesun Oct 17, 2024
e5197f3
logger
smilesun Oct 17, 2024
dc58a50
setpoint ada as argument
smilesun Oct 17, 2024
9ddd037
yaml file search setpoint ada
smilesun Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ name: CI

on:
push:
branches: fbopt
branches: mhof_dev_merge
pull_request:
branches: fbopt
branches: mhof_dev_merge
workflow_dispatch:

jobs:
test:
name: Run tests
Expand All @@ -32,7 +31,7 @@ jobs:
- name: test if api works
run: poetry run python examples/api/jigen_dann_transformer.py
- name: Generate coverage report
run: rm -r zoutput && poetry run pytest --cov=domainlab tests/ --cov-report=xml
run: rm -rf zoutput && poetry run pytest --maxfail=1 -vvv --tb=short --cov=domainlab tests/ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand All @@ -42,8 +41,14 @@ jobs:
env:
CODECOV_TOKEN: 02ecb3ac-b7ce-4ea4-90a2-961c3d1a1030
- name: check if readme yaml works
run: rm -r zoutput && python main_out.py -c ./examples/conf/vlcs_diva_mldg_dial.yaml
run: rm -rf zoutput && python main_out.py -c ./examples/conf/vlcs_diva_mldg_dial.yaml
- name: test if examples in markdown works
run: bash -x -v ci_run_examples.sh
run: bash -x -v scripts/ci_run_examples.sh
- name: test if benchmark works
run: pip install snakemake==7.32.0 && pip install pulp==2.7.0 && sed -i '1s/^/#!\/bin\/bash -x -v\n/' run_benchmark_standalone.sh && bash -x -v run_benchmark_standalone.sh examples/benchmark/demo_shared_hyper_grid.yaml && cat zoutput/benchmarks/mnist_benchmark_grid/hyperparameters.csv && cat zoutput/benchmarks/mnist_benchmark_grid/results.csv
run: |
pip install snakemake==7.32.0 && pip install pulp==2.7.0
echo "insert a shebang line (#!/bin/bash -x -v) at the beginning of the bash script"
sed -i '1s/^/#!\/bin\/bash -x -v\n/' run_benchmark_standalone.sh
bash -x -v run_benchmark_standalone.sh examples/benchmark/demo_shared_hyper_grid.yaml
cat zoutput/benchmarks/mnist_benchmark_grid*/hyperparameters.csv
cat zoutput/benchmarks/mnist_benchmark_grid*/results.csv
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.ropeproject
./zdpath
./zoutput
/zdpath
/zoutput
tests/__pycache__/
*.pyc
.vscode/
data/pacs
domainlab/zdata/pacs
/data/
/dist
/domainlab.egg-info
/runs
152 changes: 143 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,141 @@
# M-HOF-Opt: Multi-Objective Hierarchical Output Feedback Optimization via Multiplier Induced Loss Landscape Scheduling
# DomainLab: modular python package for training domain invariant neural networks

Source: https://arxiv.org/pdf/2403.13728.pdf
![GH Actions CI ](https://github.com/marrlab/DomainLab/actions/workflows/ci.yml/badge.svg?branch=master)
[![codecov](https://codecov.io/gh/marrlab/DomainLab/branch/master/graph/badge.svg)](https://app.codecov.io/gh/marrlab/DomainLab)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/bc22a1f9afb742efb02b87284e04dc86)](https://www.codacy.com/gh/marrlab/DomainLab/dashboard)
[![Documentation](https://img.shields.io/badge/Documentation-Here)](https://marrlab.github.io/DomainLab/)
[![pages-build-deployment](https://github.com/marrlab/DomainLab/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/marrlab/DomainLab/actions/workflows/pages/pages-build-deployment)

## Distribution shifts, domain generalization and DomainLab

Neural networks trained using data from a specific distribution (domain) usually fail to generalize to novel distributions (domains). Domain generalization aims at learning domain invariant features by utilizing data from multiple domains (data sites, cohorts, batches, vendors) so the learned feature can be generalized to new unseen domains (distributions).

DomainLab is a software platform with state-of-the-art domain generalization algorithms implemented and designed by maximal decoupling of different software components thus enhancing maximal code reuse.

### DomainLab
DomainLab decouples the following concepts or objects:
- task $M$: In DomainLab, a task is a container for datasets from different domains. (e.g. from distribution $D_1$ and $D_2$). The task offers a static protocol to evaluate the generalization performance of a neural network: which dataset(s) is used for training, and which dataset(s) is used for testing.
- neural network: a map $\phi$ from the input data to the feature space and a map $\varphi$ from the feature space to output $\hat{y}$ (e.g. decision variable).
- model: structural risk in the form of $\ell() + \mu R()$ where
- $\ell(Y, \hat{y}=\varphi(\phi(X)))$ is the task-specific empirical loss (e.g. cross entropy for classification task).
- $R(\phi(X))$ is the penalty loss to boost domain invariant feature extraction using $\phi$.
- $\mu$ is the corresponding multiplier to each penalty function factor.
- trainer: an object that guides the data flow to model and append further domain invariant losses
like inter-domain feature alignment.

We offer detailed documentation on how these models and trainers work on our documentation page: https://marrlab.github.io/DomainLab/

DomainLab makes it possible to combine models with models, trainers with models, and trainers with trainers in a decorator pattern like the line of code below

```
Trainer A(
Trainer B(Model C(
Model D(network E),
network E,
network F
)
)
)
```

which correspond to $\ell() + \mu_a R_a() + \mu_b R_b + \mu_c R_c() + \mu_d R_d()$, where Model C and Model D share neural network E, but Model C has an extra neural network F. All models share the same neural network for feature extraction, but can have different auxiliary networks for $R()$.

<div style="align: center; text-align:center;">
<figure>
<img src="https://github.com/marrlab/DomainLab/blob/master/docs/figs/invarfeat4dg.png?raw=true" style="width:300px;"/>
</figure>
</div>

## Getting started

### Installation
For the development version in Github, see [Installation and Dependencies handling](./docs/doc_install.md)

We also offer a PyPI version here https://pypi.org/project/domainlab/ which one could install via `pip install domainlab` and it is recommended to create a virtual environment for it.

### Task specification
We offer various ways for the user to specify a scenario to evaluate the generalization performance via training on a limited number of datasets. See detail in
[Task Specification](./docs/doc_tasks.md)

### Example and usage
#### Available arguments for commandline

The following command tells which arguments/hyperparameters/multipliers are available to be set by the user and which model they are associated with

```shell
python main_out.py --help
```

or

```
domainlab --help
```

#### Command line configuration file

`domainlab -c ./examples/conf/vlcs_diva_mldg_dial.yaml` (if you install via pip)

or if you clone this the code repository for DomainLab

`python main_out.py -c ./examples/conf/vlcs_diva_mldg_dial.yaml`

where the configuration file below can be downloaded [here](https://raw.githubusercontent.com/marrlab/DomainLab/master/examples/conf/vlcs_diva_mldg_dial.yaml)
```
te_d: caltech # domain name of test domain
tpath: examples/tasks/task_vlcs.py # python file path to specify the task
bs: 2 # batch size
model: dann_diva # combine model DANN with DIVA
epos: 1 # number of epochs
trainer: mldg_dial # combine trainer MLDG and DIAL
gamma_y: 700000.0 # hyperparameter of diva
gamma_d: 100000.0 # hyperparameter of diva
npath: examples/nets/resnet.py # neural network for class classification
npath_dom: examples/nets/resnet.py # neural network for domain classification
```
See details in [Command line usage](./docs/doc_usage_cmd.md)

#### or Programm against DomainLab API

See example here: [Transformer as feature extractor, decorate JIGEN with DANN, training using MLDG decorated by DIAL](https://github.com/marrlab/DomainLab/blob/master/examples/api/jigen_dann_transformer.py)


### Benchmark different methods
DomainLab provides a powerful benchmark functionality.
To benchmark several algorithms(combination of neural networks, models, trainers and associated hyperparameters), a single line command along with a benchmark configuration files is sufficient. See details in [benchmarks documentation and tutorial](./docs/doc_benchmark.md)

One could simply run
`bash run_benchmark_slurm.sh your_benchmark_configuration.yaml` to launch different experiments with specified configuraiton.


For example, the following result (without any augmentation like flip) is for PACS dataset using ResNet. The reader should note that using different neural network, whether pre-trained or not, what kind of preprocessinga and augmentation to use can lead to very different result distributions, which is one of the features DomainLab provide: the above factors get decoupled in DomainLab.

<div style="align: center; text-align:center;">
<figure>
<img src="https://github.com/marrlab/DomainLab/blob/master/docs/figs/stochastic_variation_two_rows.png?raw=true" style="width:800px;"/>
<div class="caption" style="align: center; text-align:center;">
<figcaption>Benchmark results plot generated from DomainLab, where each rectangle represent one model trainer combination, each bar inside the rectangle represent a unique hyperparameter index associated with that method combination, each dot represent a random seeds.</figcaption>
</div>
</figure>
</div>


### Citation

Source: https://arxiv.org/pdf/2403.14356.pdf

Citation:
```bibtex
@misc{sun2024m,
title={M-HOF-Opt: Multi-Objective Hierarchical Output Feedback Optimization via Multiplier Induced Loss Landscape Scheduling},
author={Sun, Xudong and Chen, Nutan and Gossmann, Alexej and Xing, Yu and Dorigatt, Emilio and Drost, Felix and Feistner, Carla and Scarcella, Daniele and Beer, Lisa and Marr, Carsten},
journal={https://arxiv.org/pdf/2403.13728.pdf},
number={2403.13728},
year={2024},
publisher={https://arxiv.org/pdf/2403.13728.pdf}
@misc{sun2024domainlab,
title={DomainLab: A modular Python package for domain generalization in deep learning},
author={Sun, Xudong and Feistner, Carla and Gossmann, Alexej and Schwarz, George and Umer, Rao Muhammad and Beer, Lisa and Rockenschaub, Patrick and Shrestha, Rahul Babu and Gruber, Armin and Chen, Nutan and others},
journal={https://arxiv.org/pdf/2403.14356.pdf},
year={2024}
}
```

# M-HOF-Opt: Multi-Objective Hierarchical Output Feedback Optimization via Multiplier Induced Loss Landscape Scheduling
Source: https://arxiv.org/pdf/2403.13728.pdf

M-HOF-Opt is implemented in [DomainLab](https://github.com/marrlab/DomainLab). If you meet any problems, feel free to report them at https://github.com/marrlab/DomainLab/issues

Expand Down Expand Up @@ -67,3 +189,15 @@ bash script_generate_all_figures_diva.sh
```

The resulting figures will be stored in the directory `figures_diva`, which can be changed by editing the top of the [script_generate_all_figures_diva.sh](https://github.com/marrlab/DomainLab/blob/mhof/script_generate_all_figures_diva.sh) file if needed.

Citation:
```bibtex
@misc{sun2024m,
title={M-HOF-Opt: Multi-Objective Hierarchical Output Feedback Optimization via Multiplier Induced Loss Landscape Scheduling},
author={Sun, Xudong and Chen, Nutan and Gossmann, Alexej and Xing, Yu and Dorigatt, Emilio and Drost, Felix and Feistner, Carla and Scarcella, Daniele and Beer, Lisa and Marr, Carsten},
journal={https://arxiv.org/pdf/2403.13728.pdf},
number={2403.13728},
year={2024},
publisher={https://arxiv.org/pdf/2403.13728.pdf}
}
```
1 change: 1 addition & 0 deletions a_test_feedforward_irm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --model=erm --nname=conv_bn_pool_2 --trainer=hyperscheduler_irm_dial --k_i_gain_ratio=0.5 --force_setpoint_change_once --epos=10 --epos_min=4 --exp_shoulder_clip=1 --mu_clip=100 --ini_setpoint_ratio=0.99999999
1 change: 1 addition & 0 deletions a_test_mhof_irm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --model=erm --nname=conv_bn_pool_2 --trainer=fbopt_irm_dial --k_i_gain_ratio=0.5 --force_setpoint_change_once --epos=500 --epos_min=400 --exp_shoulder_clip=1 --mu_clip=100 --ini_setpoint_ratio=0.9 --nb4reg_over_task_ratio=0 --tr_with_init_mu --coeff_ma_setpoint=0.0 --str_setpoint_ada="SliderAnyComponent()"
1 change: 0 additions & 1 deletion data/mixed_codec/caltech/auto/text.txt

This file was deleted.

Binary file removed data/mixed_codec/caltech/auto/train_imgs_150.jpg
Binary file not shown.
Binary file removed data/mixed_codec/caltech/auto/train_imgs_151.jpg
Binary file not shown.
Binary file removed data/mixed_codec/caltech/auto/train_imgs_152.png
Binary file not shown.
Binary file removed data/mixed_codec/caltech/vogel/train_imgs_1.jpg
Binary file not shown.
Binary file removed data/mixed_codec/caltech/vogel/train_imgs_2.jpg
Binary file not shown.
Binary file removed data/mixed_codec/caltech/vogel/train_imgs_3.png
Binary file not shown.
Binary file removed data/mixed_codec/sun/sofa/train_imgs_609.jpg
Binary file not shown.
Binary file removed data/mixed_codec/sun/sofa/train_imgs_612.jpg
Binary file not shown.
Binary file removed data/mixed_codec/sun/vehicle/train_imgs_17.jpg
Binary file not shown.
Binary file removed data/mixed_codec/sun/vehicle/train_imgs_19.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/dog/pic_195.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/dog/pic_304.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/elephant/pic_026.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/giraffe/pic_243.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/guitar/pic_020.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/guitar/pic_182.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/horse/pic_142.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/person/pic_165.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/person/pic_199.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/art_painting/person/pic_497.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/cartoon/dog/pic_112.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/cartoon/dog/pic_137.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/cartoon/dog/pic_219.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/cartoon/elephant/pic_332.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/cartoon/giraffe/pic_377.jpg
Binary file not shown.
Binary file removed data/pacs_mini_10/cartoon/giraffe/pic_382.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/cartoon/horse/pic_064.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/cartoon/house/pic_040.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/cartoon/person/pic_111.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/cartoon/person/pic_180.jpg
Diff not rendered.
7 changes: 0 additions & 7 deletions data/pacs_mini_10/main.sh

This file was deleted.

Binary file removed data/pacs_mini_10/photo/dog/n02103406_1011.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/elephant/n02503517_6232.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/guitar/n02676566_7830.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/horse/105_0223.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/house/pic_046.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/house/pic_110.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/house/pic_146.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/house/pic_218.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/person/253_0221.jpg
Diff not rendered.
Binary file removed data/pacs_mini_10/photo/person/253_0297.jpg
Diff not rendered.
26 changes: 0 additions & 26 deletions data/pacs_mini_10/run_with_bash_copy_files_according2txt.sh

This file was deleted.

Binary file removed data/pacs_mini_10/sketch/dog/5302.png
Diff not rendered.
Binary file removed data/pacs_mini_10/sketch/dog/5317.png
Diff not rendered.
Binary file removed data/pacs_mini_10/sketch/dog/n02103406_3255-6.png
Diff not rendered.
Binary file removed data/pacs_mini_10/sketch/elephant/5981.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed data/pacs_mini_10/sketch/guitar/n02676566_8618-2.png
Diff not rendered.
Binary file removed data/pacs_mini_10/sketch/guitar/n03467517_6423-3.png
Diff not rendered.
Diff not rendered.
Binary file removed data/pacs_mini_10/sketch/house/8873.png
Diff not rendered.
10 changes: 0 additions & 10 deletions data/pacs_split/art_painting_10.txt

This file was deleted.

100 changes: 0 additions & 100 deletions data/pacs_split/art_painting_100.txt

This file was deleted.

Loading