英文:
In hydra, can I interpolate config from a file without using the defaults list?
问题
假设我有一个名为utility_configs的目录,其中包含许多不同的配置,用于不同的情况,以不同的方式提供帮助。然后,我希望能够在不同的地方使用这些不同的配置。例如,也许我的模型有许多不同的地方,我需要一个“编码器”(实际上只是将输入映射到输出的网络部分)。我可能在utility_configs目录中有各种不同的编码器,并且我希望能够在任何需要编码器的地方指定其中任何一个(可能调整输入和输出通道的数量或其他参数)。我没有看到如何直截了当地做到这一点,因为似乎唯一从不同文件中获取数据的方式是使用默认列表。但这对于我来说并不是一个很好的选择,因为我可能需要从utility_configs中获取多个不同的东西,并且需要在多个不同的地方(包括子配置)使用它们。
英文:
Say I have a directory utility_configs that has a bunch of different configurations for different things that are useful in different situations. And then I want to be able to use these different configs in different places. For instance, maybe my model has many different places where I need something that is an "encoder" (really just a bit of network that maps an input to an output). I might have vary different encoders in my utility_configs directory, and I would like to be able to specify any of them anyplace I need an encoder (possibly then adjusting the number of input and output channels or other parameters). I am not seeing how to do this straightforwardly since it seems like the only way you can get data from a different file is using the defaults list. But that's not really a good fit here since I might need multiple different things from utility_configs and in multiple different places (including subconfigs)
答案1
得分: 1
无法对文件进行插值。插值操作在当前配置对象上进行。
Hydra可以为您组合配置,之后您可以使用插值。
您有多个选项:
- 拥有多个主配置(带有默认列表)。您可以通过命令行 (
--config-name|-cn) 来覆盖要使用的主配置。 - 通过命令行以
+GROUP=OPTION标记的方式,以临时方式构建默认列表(参见此处)。
关于在不同位置使用配置,请查看配置包 - 这使您能够在组合的配置对象中重新定位配置内容。
我建议选择第1种方式。
英文:
You cannot interpolate into a file. Interpolation works on the current config object.
Hydra can compose the config for you, after which you can use interpolation.
You have multiple options:
- Have more than one primary config (with a defaults list). You can override which primary config to use via the command line (
--config-name|-cn). - Construct your defaults list in an ad-hoc manner via the command line using the
+GROUP=OPTIONnotation (see this).
About using a config in different places, take a look at config packages - which allows you to relocate the content of a config in the composed config object.
I recommend going with 1.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论