Using Enums with Hydra's instantiate? #2811
Answered
by
odelalleau
stwerner97
asked this question in
Q&A
-
Hi, how can I instantiate an enum with Hydra's instantiate method? The code below throws an error, because the Enum does not take an argument from enum import Enum
from omegaconf import OmegaConf
from hydra.utils import instantiate
class MyEnum(Enum):
DNN = "DeepNeuralNetwork"
cfg = OmegaConf.create(
{"_target_": "script.MyEnum", "DNN": "DeepNeuralNetwork"}
)
myenum = instantiate(cfg) |
Beta Was this translation helpful? Give feedback.
Answered by
odelalleau
Dec 1, 2023
Replies: 1 comment 1 reply
-
Indeed it shouldn't be a keyword argument, instead use: cfg = OmegaConf.create(
{"_target_": "script.MyEnum", "_args_": ["DeepNeuralNetwork"]}
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
stwerner97
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Indeed it shouldn't be a keyword argument, instead use: