如何引用Hydra Conf文件夹的其他.YAML文件?

发布于 2025-02-03 20:53:30 字数 646 浏览 5 评论 0原文

我的conf目录看起来像:

conf
- hydra
 - run
   - dir
    - job_timestamp.yaml
main.yaml

在main.yaml中,我试图用Job_timestamp.yaml中定义的自定义结构覆盖Hydra输出目录:

dir: ./outputs/${status}/${now:%Y-%m-%d}/${now:%H-%M-%S}

但是,写作:

hydra:
  run:
    dir: job_timestamp

Main.yaml不参考hydra/run/run/dir/dir/job_timestamp我拥有的.yaml文件 - 实际上,它只是使输出文件夹名称“ job_timestamp”

我想知道如何在main.yaml中引用我的job_timestamp.yaml文件来覆盖Hydra的输出目录配置。

编辑: 我最初在main.yaml的默认值下有hydra/run/dir:job_timestamp。我打算拥有不同版本的main.yaml(例如main2.yaml,evaluate.yaml等),所有这些都需要以相同的格式覆盖输出目录,是否有一种方法可以做到这一点,以使其干燥?

My conf directory looks like:

conf
- hydra
 - run
   - dir
    - job_timestamp.yaml
main.yaml

in main.yaml I am trying to overwrite the hydra output directory with a custom structure as defined in job_timestamp.yaml:

dir: ./outputs/${status}/${now:%Y-%m-%d}/${now:%H-%M-%S}

However, writing:

hydra:
  run:
    dir: job_timestamp

in main.yaml doesn't reference the hydra/run/dir/job_timestamp.yaml file I have - it actually just makes the output folder name "job_timestamp"

I was wondering how I would reference my job_timestamp.yaml file in main.yaml to overwrite hydra's output directory config.

EDIT:
I originally had hydra/run/dir: job_timestamp under defaults of main.yaml, however, it would return with hydra/run/dir not found in defaults list. I am planning to have different versions of main.yaml (e.g. main2.yaml, evaluate.yaml etc.) which all would need to override the output directory with the same format, is there a way to do this so that it is DRY?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福还没到 2025-02-10 20:53:31

您似乎在Hydra(例如配置值和配置组)中令人困惑的基本概念。
您不仅从默认列表中“引用”配置值的配置文件。

返回基本教程,并确保您了解配置组。
Hydra特定的配置组是在Hydra软件包中定义的(在这里)。您可能需要通过配置组覆盖Hydra配置 - 但是我只建议您在对配置组有更好的了解后尝试。
同时,您可以通过直接将其直接覆盖在您的main.yaml文件中:

main.yaml

hydra:
  run:
    dir: outputs/${status}/${now:%Y-%m-%d}/${now:%H-%M-%S}

You seem to be confusing basic concepts in Hydra like config values and config groups.
You do not "reference" a config file from a config value, only from the defaults list.

Go back to the basic tutorial and make sure you understand config groups.
Hydra specific config groups are defined inside the Hydra package (here). You may want to override Hydra configs via config groups - but I only suggest you attempt that after you have a better understanding of config groups.
In the mean time, you can do it by simply overriding it directly in your main.yaml file:

main.yaml:

hydra:
  run:
    dir: outputs/${status}/${now:%Y-%m-%d}/${now:%H-%M-%S}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文