【发布时间】:2021-07-20 14:50:17
【问题描述】:
这是文件目录:
|-configs
|----data_conf
|--------csv_images.csv
|--------tf_ds.csv
|----example.yaml
而example.yaml 是:
data: csv_images
defaults:
- data_conf: "${data}"
和csv_images.yaml:
# @package _group_
a: test_a
b: test_b
我的意图是 hydra 将 csv_images 替换为 csv_images.yaml。意思是,example.yaml 在运行时的解释是:
data:
a: test_a
b: test_b
我这样定义了ConfigStore:
config_name = "example"
cs = ConfigStore.instance()
cs.store(name=config_name, node=Config)
cs.store(group='data_conf', name='csv_images', node=DatasetConfig)
Config 和 DatasetConfig 是这样定义的:
@dataclass
class Config:
data: Any = MISSING
@dataclass
class DatasetConfig:
a: str = MISSING
b: str = MISSING
但是,当我运行我的程序时,我收到以下错误:
Interpolation key 'data' not found
full_key: defaults[0].data_conf
object_type=dict
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
当我将data_conf 定义为csv_images 时,它工作正常并执行运行时检查。但是,使用 ${} 进行插值不会。那是什么,我能做什么?
【问题讨论】:
标签: python fb-hydra hydra-python omegaconf