[Python] Interpolating with Hydra

Discussão em 'Python' iniciado por Stack, Agosto 3, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Hydra to organise configs for an ML project and I have my main config file along the lines of:

    config.yaml

    defaults:
    - model: model_a
    - _self_


    then in

    model/model_a.yaml

    feature_dim: 106
    block_args:
    layer_1:
    input_dim: ${feature_dim}
    embed_dim: 64
    output_dim: 64
    layer_2:
    ...


    expecting ${feature_dim} to get the value of 106 so I only have to change it in one place, but when I print the model config I get {'feature_dim': 106, 'block_args': {'layer_1': {'input_dim': '${feature_dim}', 'embed_dim': 64, 'output_dim': 64}, 'layer_2': ...}

    This should be fairly simple and I don't understand why it's not working, any suggestions would be greatly appreciated!

    Continue reading...

Compartilhe esta Página