本文整理汇总了Python中sacred.Ingredient方法的典型用法代码示例。如果您正苦于以下问题:Python sacred.Ingredient方法的具体用法?Python sacred.Ingredient怎么用?Python sacred.Ingredient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sacred
的用法示例。
在下文中一共展示了sacred.Ingredient方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_named_config_and_ingredient
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def test_named_config_and_ingredient():
ing = Ingredient("foo")
@ing.config
def cfg():
a = 10
ex = Experiment(ingredients=[ing])
@ex.config
def default():
b = 20
@ex.named_config
def named():
b = 30
@ex.main
def main():
pass
r = ex.run(named_configs=["named"])
assert r.config["b"] == 30
assert r.config["foo"] == {"a": 10}
示例2: test_format_named_configs
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def test_format_named_configs():
ingred = Ingredient("ingred")
ex = Experiment(name="experiment", ingredients=[ingred])
@ingred.named_config
def named_config1():
pass
@ex.named_config
def named_config2():
"""named config with doc"""
pass
dict_config = dict(v=42)
ingred.add_named_config("dict_config", dict_config)
named_configs_text = _format_named_configs(OrderedDict(ex.gather_named_configs()))
assert named_configs_text.startswith(
"Named Configurations (" + COLOR_DOC + "doc" + ENDC + "):"
)
assert "named_config2" in named_configs_text
assert "# named config with doc" in named_configs_text
assert "ingred.named_config1" in named_configs_text
assert "ingred.dict_config" in named_configs_text
示例3: cfg1
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def cfg1():
verbose = True
# ============== Ingredient 1: dataset.paths =================
示例4: cfg2
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def cfg2(settings):
v = not settings["verbose"]
base = "/home/sacred/"
# ============== Ingredient 2: dataset =======================
示例5: cfg2
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def cfg2():
filename = "foo.npy"
# add the Ingredient while creating the experiment
示例6: add_task
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def add_task(task_name: str, task: Type[Task], params: Optional[Ingredient] = None) -> None:
assert isinstance(task, type)
TaskBuilder.tasks[task_name] = task
if params is not None:
TaskBuilder.params.append(params)
示例7: add_model
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def add_model(model_name: str,
model: Type[AbstractTapeModel],
hparams: Optional[Ingredient] = None) -> None:
if not issubclass(model, AbstractTapeModel):
raise TypeError("Model is not a subclass of AbstractTapeModel")
if hparams is not None and not isinstance(hparams, Ingredient):
raise TypeError("hparams object is not a sacred Ingredient")
ModelBuilder.models[model_name] = model
if hparams is not None:
ModelBuilder.hparams.append(hparams)
示例8: mkdir_p
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def mkdir_p(path):
# http://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
# ============== Ingredient 2: dataset =======================