Skip to content

Commit a77dad8

Browse files
authored
Merge pull request #804 from marrlab/usage-guide
Extend usage guide
2 parents cd6ad64 + 0428acb commit a77dad8

1 file changed

Lines changed: 97 additions & 22 deletions

File tree

docs/doc_usage_cmd.md

Lines changed: 97 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,115 @@
1-
### Basic usage
2-
DomainLab comes with some minimal toy-dataset to test its basis functionality, see [A minimal subsample of the VLCS dataset](../data/vlcs_mini) and [an example configuration file for vlcs_mini](../examples/tasks/task_vlcs.py)
1+
# DomainLab Usage Guide
32

4-
Suppose you have cloned the repository and have the dependencies ready, change directory to this repository:
3+
Given the repository and the dependencies are set up, here is how can use DomainLab:
54

6-
To train a domain invariant model on the vlcs_mini task
5+
6+
## Essential Commands
7+
8+
To run DomainLab, the minimum necessary parameters are:
9+
10+
1. **Task Specification (```--tpath``` or ```--task```):** This is to specify a task. You can eiter give a path to as Python file which specifies the task, or use a predfined set. You can find more about specifying tasks [here](./doc_tasks.md).
11+
2. **Test Domain (```--te_d```):** Specifies the domain(s) used for testing. Can be a single domain or multiple domains.
12+
3. **Model Choice (```--model```):** Chooses the algorithm or model for the training (e.g., erm, diva). This also includes hyperparameters for the model, e.g., ```--gamma_d``` and ```--gamma_y``` for diva.
13+
4. **Neural Network (```--nname``` or ```--npath```):** Specifies which neural network is used for feature extraction, either through a path or predefined options.
14+
15+
### Example Command
16+
```python3 main_out.py --te_d 0 1 2 --task=mnistcolor10 --model=diva --nname=conv_bn_pool_2 --gamma_y=7e5 --gamma_d=1e5```
17+
18+
19+
## Optional Commands
20+
21+
### Advanced Configuration
22+
23+
- **Learning Rate (`--lr`):** Set the training learning rate.
24+
- **Regularization (`--gamma_reg`):** Weight of regularization loss.
25+
- **Early Stopping (`--es`):** Steps for early stopping.
26+
- **Random Seed (`--seed`):** Seed for reproducibility.
27+
- **CUDA Options (`--nocu`, `--device`):** Configure CUDA usage and device settings.
28+
- **Generated Images (`--gen`):** Option to save generated images.
29+
- **Model Preservation (`--keep_model`):** Choose not to delete the model at the end of training.
30+
- **Epochs (`--epos`, `--epos_min`):** Configure maximum and minimum numbers of epochs.
31+
- **Test Interval (`--epo_te`):** Set intervals for testing performance.
32+
- **Hyperparameter Warm-Up (`-w` or `--warmup`):** Epochs for hyperparameter warm-up.
33+
- **Debugging (`--debug`):** Enable debug mode for verbose output.
34+
- **Memory Debugging (`--dmem`):** Memory usage debugging.
35+
- **Output Suppression (`--no_dump`):** Suppress saving the confusion matrix.
36+
- **Trainer Selection (`--trainer`):** Specify which trainer to use.
37+
- **Output Directory (`--out`):** Directory to store outputs.
38+
- **Data Path (`--dpath`):** Path for storing the downloaded dataset.
39+
- **Additional Neural Network Options:**
40+
- Custom Argument Values (`--npath_argna2val`, `--nname_argna2val`)
41+
- Domain Feature Extraction Network (`--npath_dom`, `--nname_dom`)
42+
- Custom Algorithm Path (`--apath`)
43+
- **Experiment and Aggregation Tags (`--exptag`, `--aggtag`):** Tags for experiment tracking and result aggregation.
44+
- **Benchmarking and Plotting:**
45+
- Partial Benchmark Aggregation (`--agg_partial_bm`)
46+
- Plot Generation (`--gen_plots`, `--outp_dir`, `--param_idx`)
47+
48+
### Task-Specific Arguments
49+
50+
- **Batch Size (`--bs`):** Loader batch size for mixed domains.
51+
- **Training-Validation Split (`--split`):** Proportion of training, a value between 0 and 1.
52+
- **Training Domain (`--tr_d`):** Specify training domain names.
53+
- **Sanity Check (`--san_check`):** Save images from the dataset as a sanity check.
54+
- **Sanity Check Image Count (`--san_num`):** Number of images for the sanity check.
55+
- **Logging Level (`--loglevel`):** Set the log level of the logger.
56+
- **Shuffling (`--shuffling_off`):** Disable shuffling of the training dataloader for the dataset.
57+
58+
### Model-Specific Hyperparameters
59+
60+
#### VAE Model Parameters
61+
62+
- **Latent Space Dimensions (`--zd_dim`, `--zx_dim`, `--zy_dim`):** Set the size of latent spaces for domain, unobserved, and class features.
63+
- **Topic Dimension (`--topic_dim`):** Number of topics for HDUVA.
64+
- **Networks for HDUVA Model:**
65+
- Image to Topic Distribution (`--nname_encoder_x2topic_h`, `--npath_encoder_x2topic_h`)
66+
- Image and Topic to ZD (`--nname_encoder_sandwich_x2h4zd`, `--npath_encoder_sandwich_x2h4zd`)
67+
- **Hyperparameters for DIVA and HDUVA (`--gamma_y`, `--gamma_d`, `--beta_t`, `--beta_d`, `--beta_x`, `--beta_y`):** Multipliers for various classifiers and loss components.
68+
69+
#### MatchDG Parameters
70+
71+
- **Cosine Similarity Factor (`--tau`):** Magnify cosine similarity.
72+
- **Match Tensor Update Frequency (`--epos_per_match_update`):** Epochs before updating the match tensor.
73+
- **Epochs for CTR (`--epochs_ctr`):** Total epochs for CTR.
74+
75+
#### Jigen Parameters
76+
77+
- **Permutation Settings (`--nperm`, `--pperm`, `--jigen_ppath`):** Configure image tile permutations.
78+
- **Grid Length (`--grid_len`):** Length of image in tile units.
79+
80+
#### DIAL Parameters
81+
82+
- **Adversarial Image Generation (`--dial_steps_perturb`, `--dial_noise_scale`, `--dial_lr`, `--dial_epsilon`):** Configure parameters for generating adversarial images.
83+
84+
85+
For a comprehensive understanding of all available commands, use:
86+
```shell
87+
python main_out.py --help
88+
```
89+
90+
## Example
91+
DomainLab comes with some minimal toy-dataset to test its basis functionality, see [a minimal subsample of the VLCS dataset](../data/vlcs_mini) and [an example configuration file for vlcs_mini](../examples/tasks/task_vlcs.py).
92+
93+
To train a domain invariant model on the vlcs_mini task:
794

895
```shell
996
python main_out.py --te_d=caltech --tpath=examples/tasks/task_vlcs.py --config=examples/yaml/demo_config_single_run_diva.yaml
1097
```
1198
where `--tpath` specifies the path of a user specified python file which defines the domain generalization task [see here](../examples/tasks/task_vlcs.py), `--te_d` specifies the test domain name (or index starting from 0), `--config` specifies the configurations of the domain generalization algorithms, [see here](../examples/yaml/demo_config_single_run_diva.yaml)
1299

13-
#### Further usage
14-
Alternatively, in a verbose mode without using the algorithm configuration file:
100+
In more detail, in a verbose mode without using the algorithm configuration file:
15101

16102
```shell
17103
python main_out.py --te_d=caltech --tpath=examples/tasks/task_vlcs.py --debug --bs=2 --model=diva --gamma_y=7e5 --gamma_d=1e5 --nname=alexnet --nname_dom=conv_bn_pool_2
18104
```
19105

20106
where `--model` specifies which algorithm to use, `--bs` specifies the batch size, `--debug` restrain only running for 2 epochs and save results with prefix 'debug'. For DIVA, the hyper-parameters include `--gamma_y=7e5` which is the relative weight of ERM loss compared to ELBO loss, and `--gamma_d=1e5`, which is the relative weight of domain classification loss compared to ELBO loss.
21107
`--nname` is to specify which neural network to use for feature extraction for classification, `--nname_dom` is to specify which neural network to use for feature extraction of domains.
22-
For usage of other arguments, check with
23-
24-
```shell
25-
python main_out.py --help
26-
```
27-
28-
See also [Examples](./doc_examples.md).
29-
30-
### Custom Neural network
31-
32-
where the user could plugin different neural network architectures for the same algorithm. See
33-
[Specify Custom Neural Networks for an algorithm](./doc_custom_nn.md)
34108

35-
### Output structure (results storage) and Performance Measure
36-
[Output structure and Performance Measure](./doc_output.md)
109+
See [more examples](./doc_examples.md).
37110

111+
## Further Resources
38112

39-
## Software Design Pattern, Extend or Contribution
40-
[Extend or Contibute](./doc_extend_contribute.md)
113+
- **Custom Neural Networks:** [Guide on specifying custom neural networks](./doc_custom_nn.md)
114+
- **Output and Performance:** [Understanding the output structure and performance measures](./doc_output.md)
115+
- **Extending DomainLab:** [Guide for extending or contributing to DomainLab](./doc_extend_contribute.md)

0 commit comments

Comments
 (0)