当前位置: 首页>>代码示例>>Python>>正文


Python sacred.Ingredient方法代码示例

本文整理汇总了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} 
开发者ID:IDSIA,项目名称:sacred,代码行数:26,代码来源:test_experiment.py

示例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 
开发者ID:IDSIA,项目名称:sacred,代码行数:26,代码来源:test_commands.py

示例3: cfg1

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def cfg1():
    verbose = True


# ============== Ingredient 1: dataset.paths ================= 
开发者ID:IDSIA,项目名称:sacred,代码行数:7,代码来源:modular.py

示例4: cfg2

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def cfg2(settings):
    v = not settings["verbose"]
    base = "/home/sacred/"


# ============== Ingredient 2: dataset ======================= 
开发者ID:IDSIA,项目名称:sacred,代码行数:8,代码来源:modular.py

示例5: cfg2

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Ingredient [as 别名]
def cfg2():
    filename = "foo.npy"


# add the Ingredient while creating the experiment 
开发者ID:IDSIA,项目名称:sacred,代码行数:7,代码来源:ingredient.py

示例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) 
开发者ID:songlab-cal,项目名称:tape-neurips2019,代码行数:8,代码来源:TaskBuilder.py

示例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) 
开发者ID:songlab-cal,项目名称:tape-neurips2019,代码行数:15,代码来源:ModelBuilder.py

示例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 ======================= 
开发者ID:keras-team,项目名称:keras-contrib,代码行数:14,代码来源:coco.py


注:本文中的sacred.Ingredient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。