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