Search code examples
fb-hydra

How to create two fields from the same group in hydra-python?


My config files structure:

config
├── train_dataset
│   ├── adobe5k.yaml
│   ├── my_train_data1.yaml
│   └── cifar10.yaml
├── valid_dataset
│   ├── adobe5k.yaml
│   └── cifar10.yaml
└── config.yaml

And my config.yaml is:

# other configs
...

defaults:
  - train_dataset: adobe5k
  - valid_dataset: adobe5k

As you see, I have 2 fields named valid_dataset and train_dataset in my config, whose value is selected from its own config group. What should I do to make values of the two fields selected from the same group?


Solution

  • You can use a config group more than once. Assume that you moved your dataset configurations into a single datasets directory. Then you can re-use them as follows.

    - defaults:
      - datasets@train_dataset: adobe5k
      - datasets@valid_dataset: adobe5k