问题标签 [omegaconf]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
fb-hydra - 如何在配置中多次重用包?
我有一个通用的摄像头配置 yaml,通常在特定摄像头之间唯一改变的是 IP 地址。某些字段(在以下示例中fps
)保持不变。
我可以在 Hydra/OmegaConf 中做这样的事情吗?
any_camera.yaml
all_cameras.yaml
python - 使用 omegaconf 在 YAML 配置文件中进行算术操作
目前,我有这个配置文件,我用它作为hydra/omegaconf的输入
由于范围字段中的值与简单代数相关,因此我正在寻找一种将其编码到配置文件中的方法。从概念上讲,我想要这样的东西:
但这似乎不起作用。
python - 将 hydra/omegaconf 配置转换为 python 嵌套字典/列表?
我想将 OmegaConf/Hydra 配置转换为嵌套字典/列表。我怎样才能做到这一点?
python - Hydra instantiation of tuple resolved from OmegaConf custom resolver fails for nested config files
OmegaConf allows you to register a custom resolver. Here is an example of resolving a tuple.
This can be used to resolve a value in a config file with a structure like ${tuple:1,2}
to a tuple (1, 2)
. Along with hydra.utils.instantiate
this can be used to create objects that contain or utilize tuples. For example:
config.yaml
test.py
Running this example returns:
However, imagine you had a much more complex config structure. You may want to use interpolation to bring in configs from other files like so.
tuple/base.yaml
config.yaml
Running this example you get an error:
The full traceback from hydra is:
If you really dig around in the omegaconf code in the trace you will find that there is a flag for the config object allow_objects
that is True
in the example that passes and None
in the example that does not. What is interesting is that in the _instantaite2.py
file just before calling Omegaconf.resolve(config)
several flags are set, one being allow_objects
as True
.
Is the intended behavior for these interpolated/resolved values populated from separate files to override this flag? If so, is there some way to ensure that the allow_objects
flag is (or remains) true for all resolved and interpolated values?
python - Hydra:从代码中访问配置文件的名称
我有一个配置树,例如:
其中config.yaml
包含:
我想从我的 python 代码或文件本身访问使用的模型配置文件的名称(默认或覆盖)。就像是:
或(来自例如model_a.yaml
)
提前致谢!
python - 读取用`oc.env`解析的变量作为hydra中的整数
在我的项目中,我正在使用 python-dotenv 设置环境变量。co.env
然后我使用OmegaConf 解析器在我的 YAML 中引用它。
然而,一旦我运行我的脚本,该变量似乎总是被解析为一个字符串:
据我从这里了解到,这是 的预期行为oc.env
,并且env
会猜测原始类型的解析器已被弃用。
如何确保将var2
其读取为整数?
提前致谢。
python - Hydra:从子节点插入变量
给定以下配置文件:
我想构造一个MainClass类型的对象,它采用ChildClass类型的对象。ChildClass
的参数之一也用于MainClass的构造函数。
如何a
使用参数插值读取子属性?
fb-hydra - 如何设置 hydra 配置以接受自定义枚举?
如何设置我的 hydra 配置以接受自定义枚举?具体来说,我遵循了结构化配置模式教程。
我有一个数据类配置:
使用自定义枚举:
运行出错python my_app.py
刚刚在哪里my_app.py
:
而里面的配置data/config.yaml
只是
python-3.x - use data types or other library-specific variables as arguments in hydra
I would like to use python datatypes - both built-in and imported from libraries such as numpy, tensorflow, etc - as arguments in my hydra configuration. Something like:
I'm currently doing this instead:
Is there a more hydronic/elegant solution? Thanks!
python - 是否可以让配置键成为 Hydra 中变量插值的结果?
假设以下配置结构:
config.yaml
:
model/default.yaml
:
以下不起作用:
data/default.yaml
:
有没有办法让这样的工作?还是等效的替代方案?