當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。