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


Python sacred.Experiment方法代码示例

本文整理汇总了Python中sacred.Experiment方法的典型用法代码示例。如果您正苦于以下问题:Python sacred.Experiment方法的具体用法?Python sacred.Experiment怎么用?Python sacred.Experiment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sacred的用法示例。


在下文中一共展示了sacred.Experiment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_format_named_configs

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [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

示例2: test_format_filtered_stacktrace_true

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def test_format_filtered_stacktrace_true():
    ex = Experiment("exp")

    @ex.capture
    def f():
        raise Exception()

    try:
        f()
    except:
        st = format_filtered_stacktrace(filter_traceback="default")
        assert "captured_function" not in st
        assert "WITHOUT Sacred internals" in st

    try:
        f()
    except:
        st = format_filtered_stacktrace(filter_traceback="always")
        assert "captured_function" not in st
        assert "WITHOUT Sacred internals" in st 
开发者ID:IDSIA,项目名称:sacred,代码行数:22,代码来源:test_exceptions.py

示例3: test_run_waits_for_running_queue_observer

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def test_run_waits_for_running_queue_observer():

    queue_observer_with_long_interval = QueueObserver(
        mock.MagicMock(), interval=1, retry_interval=0.01
    )

    ex = Experiment("ator3000")
    ex.observers.append(queue_observer_with_long_interval)

    @ex.main
    def main():
        print("do nothing")

    ex.run()
    assert (
        queue_observer_with_long_interval._covered_observer.method_calls[-1][0]
        == "completed_event"
    ) 
开发者ID:IDSIA,项目名称:sacred,代码行数:20,代码来源:test_queue_observer.py

示例4: test_run_waits_for_running_queue_observer_after_failure

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def test_run_waits_for_running_queue_observer_after_failure():

    queue_observer_with_long_interval = QueueObserver(
        mock.MagicMock(), interval=1, retry_interval=0.01
    )

    ex = Experiment("ator3000")
    ex.observers.append(queue_observer_with_long_interval)

    @ex.main
    def main():
        raise Exception("fatal error")

    try:
        ex.run()
    except:
        pass

    assert (
        queue_observer_with_long_interval._covered_observer.method_calls[-1][0]
        == "failed_event"
    ) 
开发者ID:IDSIA,项目名称:sacred,代码行数:24,代码来源:test_queue_observer.py

示例5: grid_search_all_images

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def grid_search_all_images(dataset, elemental):
    """
    CML command which starts a grid search for a all images of the dataset.

    :param dataset: Dataset name
    :type dataset: String
    :param elemental: General experiment configuration parameters
    :type elemental: Dict
    """
    # pylint:disable=no-value-for-parameter
    # pylint:disable=unused-variable
    grid_params = init_grid_params()
    start_grid_search(ex.path, experiment_all_images_wrapper, [dataset], grid_params)


##
## Experiment
## 
开发者ID:tum-vision,项目名称:learn_prox_ops,代码行数:20,代码来源:experiment_demosaicking.py

示例6: foo

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def foo(basepath, filename, paths, settings):
    print(paths)
    print(settings)
    return basepath + filename


# ============== Experiment ============================== 
开发者ID:IDSIA,项目名称:sacred,代码行数:9,代码来源:modular.py

示例7: stats

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def stats(filename, foo=12):
    print('Statistics for dataset "{}":'.format(filename))
    print("mean = 42.23")
    print("foo=", foo)


# ================== Experiment =============================================== 
开发者ID:IDSIA,项目名称:sacred,代码行数:9,代码来源:ingredient.py

示例8: ex

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def ex():
    return Experiment("Test experiment") 
开发者ID:IDSIA,项目名称:sacred,代码行数:4,代码来源:test_metrics_logger.py

示例9: test_circular_dependency_raises

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def test_circular_dependency_raises():
    # create experiment with circular dependency
    ing = Ingredient("ing")
    ex = Experiment("exp", ingredients=[ing])
    ex.main(lambda: None)
    ing.ingredients.append(ex)

    # run and see if it raises
    with pytest.raises(CircularDependencyError, match="exp->ing->exp"):
        ex.run() 
开发者ID:IDSIA,项目名称:sacred,代码行数:12,代码来源:test_exceptions.py

示例10: test_missing_config_raises

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def test_missing_config_raises():
    ex = Experiment("exp")
    ex.main(lambda a: None)
    with pytest.raises(MissingConfigError):
        ex.run() 
开发者ID:IDSIA,项目名称:sacred,代码行数:7,代码来源:test_exceptions.py

示例11: test_named_config_not_found_raises

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def test_named_config_not_found_raises():
    ex = Experiment("exp")
    ex.main(lambda: None)
    with pytest.raises(
        NamedConfigNotFoundError,
        match='Named config not found: "not_there". ' "Available config values are:",
    ):
        ex.run(named_configs=("not_there",)) 
开发者ID:IDSIA,项目名称:sacred,代码行数:10,代码来源:test_exceptions.py

示例12: test_format_filtered_stacktrace_false

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def test_format_filtered_stacktrace_false():
    ex = Experiment("exp")

    @ex.capture
    def f():
        raise Exception()

    try:
        f()
    except:
        st = format_filtered_stacktrace(filter_traceback="never")
        assert "captured_function" in st 
开发者ID:IDSIA,项目名称:sacred,代码行数:14,代码来源:test_exceptions.py

示例13: ex

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def ex():
    return Experiment("tensorflow_tests") 
开发者ID:IDSIA,项目名称:sacred,代码行数:4,代码来源:test_method_interception.py

示例14: ex

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def ex():
    return Experiment("ator3000") 
开发者ID:IDSIA,项目名称:sacred,代码行数:4,代码来源:test_tinydb_observer_not_installed.py

示例15: fetch_parents

# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def fetch_parents(current_path):
    tmp_ex = Experiment('jack')
    if not isinstance(current_path, list):
        current_path = [current_path]
    all_paths = list(current_path)
    for p in current_path:
        tmp_ex.add_config(p)
        if "parent_config" in tmp_ex.configurations[-1]._conf:
            all_paths = fetch_parents(tmp_ex.configurations[-1]._conf["parent_config"]) + all_paths
    return all_paths 
开发者ID:uclnlp,项目名称:jack,代码行数:12,代码来源:jack-train.py


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