问题标签 [fb-hydra]

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.

0 投票
1 回答
55 浏览

fb-hydra - 使用显式嵌套专门化 Hydra 配置

我想拥有:

在 中config.yamltext/font.yaml分配给fonttext/regions.yaml的地方regions,例如:

或者

以上都行不通!

是否有可能以yaml某种方式在该级别达到预期的结果?

0 投票
1 回答
282 浏览

fb-hydra - 在 hydra-python 结构化配置中,如何插入值?

我正在使用@dataclass带有 hydra 1.1 的结构化配置(基于 -)并尝试插入一些值。具体来说,我想通过替换我的一些配置值来设置工作目录。

使用 yaml 时,我可以通过查阅文档来做到这一点:

如何使用结构化配置来做到这一点?

0 投票
1 回答
146 浏览

python - 将 hydra 实例化目标的参数定义为 2 的幂

在使用实例化时,有没有办法为目标定义一个 2 的幂的参数?例如:

正如预期的那样,输出是一个稀疏向量,其形状为 (1, 262144),相当于 2**18。

但是,在配置文件中,您不能使用该值2**18,因为它是作为字符串传入的。

配置.yaml

测试.py

运行此示例,您将获得以下信息:

有没有办法通知 hydra 该值不应被视为字符串?

0 投票
3 回答
174 浏览

python-3.x - 如何获取 Hydra 生成的运行日期和时间?

我在 Python 项目中使用hydra 。我的 yaml 配置文件包含以下几行:

在我的代码中,我想获取 hydra 用于创建其输出文件夹结构的日期和时间。如果 hydra 有一个内置函数可以返回一个str或一个Datetime包含从${now:%Y-%m-%d}/${now:%H-%M-%S}.

如果没有,我仍然可以解析 hydra 设置的当前路径(我可以通过 获取os.getcwd())或使用Dictconfighydra 从上面的 yaml 创建的信息,但这会不太方便。

0 投票
1 回答
121 浏览

python - 限制 hydra 结构化配置中的可能值

我尝试将我的应用程序用于hydra框架。我使用结构化配置模式,我想限制某些字段的可能值。有没有办法做到这一点?

这是我的代码:

我的应用程序.py:

配置/config.yaml:

0 投票
0 回答
97 浏览

python - 使用未与已安装的 Hydra 应用程序打包的配置

在打包 Hydra 应用程序并包含一个脚本作为入口点时,可以在任何地方从命令行调用该脚本。调用该脚本时,将使用包中包含的配置。有没有办法修改配置搜索路径,以便可以将不同的配置传递给脚本?

例如:

应用程序.py

配置.yaml

使用entry_points={"console_scripts": ["hydra_app_test = hydra_app_test.app:my_func"]}.

我希望能够定义一个本地配置并将其传递给hydra_test_app. 这样的事情可能吗?

一些/config/path/config.yaml

我曾尝试使用--config-dirand--config-path覆盖,但没有任何运气。

有趣的是,如果您不使用已安装的应用程序,但将 app.py 作为脚本运行(具有必要的if __name__ == "__main__"逻辑) ,则此模式有效

也许我只是在这里遗漏了一些东西,但看起来你应该能够为已安装的包脚本和 python 脚本复制相同的行为。

0 投票
2 回答
425 浏览

python - 如何从 hydra 配置文件传递字典元素

我正在尝试用 hydra 实例化对象,我有一个torchio.transforms.RemapLabels在我的配置文件中使用的类:

问题是torchio.transforms.RemapLabels将字典元素作为输入,我如何从我的 hydra 配置文件中传递这些元素?( config.yaml)?

实例化时出现错误:

重映射标签的示例用法:

0 投票
1 回答
360 浏览

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?

0 投票
2 回答
94 浏览

fb-hydra - 在文件或文件夹上使用 glob 进行多重运行

假设目录结构如下:

我想多次运行使用 Hydra 配置的脚本,每次都获取其中一个input*文件夹的完整路径。

这怎么可能实现?

0 投票
1 回答
135 浏览

python - Hydra:从代码中访问配置文件的名称

我有一个配置树,例如:

其中config.yaml包含:

我想从我的 python 代码或文件本身访问使用的模型配置文件的名称(默认或覆盖)。就像是:

或(来自例如model_a.yaml

提前致谢!