本文整理汇总了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
示例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
示例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"
)
示例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"
)
示例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
##
示例6: foo
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def foo(basepath, filename, paths, settings):
print(paths)
print(settings)
return basepath + filename
# ============== Experiment ==============================
示例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 ===============================================
示例8: ex
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def ex():
return Experiment("Test experiment")
示例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()
示例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()
示例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",))
示例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
示例13: ex
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def ex():
return Experiment("tensorflow_tests")
示例14: ex
# 需要导入模块: import sacred [as 别名]
# 或者: from sacred import Experiment [as 别名]
def ex():
return Experiment("ator3000")
示例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