hydra composition for ML models

I have some configurations for ML components as follows:

ml/encoder.yaml

hidden_layers_sizes: [2000, 1000, 300]
z_dim: 50

ml/decoder.yaml

hidden_layers_sizes: [300, 1000, 2000]
z_dim: 50

Now I have another configuration file as models/vae.yaml which I want to define as having these encoder and decoder configurations.

So the whole thing is structured as:

- conf
  - ml
    - encoder.yaml
    - decoder.yaml
  - models
    - vae.yaml

How should I define in vae.yamlso that the configuration of the encoders and decoders can be passed down to the underlying object (and be overridden if possible by the command line)?

I tried something like:

# @package _global_

defaults:
  - override /ml/encoder: encoder
  - override /ml/decoder: decoder

However, this results in Could not override 'ml/encoder'. No match in the defaults list.


Solution 1:

I managed to get it working as:

defaults:
 - encoder: vae_encoder
 - decoder: vae_decoder

I changed the config to look as:

- conf
  - models
    - encoder
      - encoder.yaml
    - decoder
      - decoder.yaml
    - vae.yaml