Python sacred.Ingredient() Examples
The following are 8
code examples of sacred.Ingredient().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sacred
, or try the search function
.
Example #1
Source File: test_experiment.py From sacred with MIT License | 6 votes |
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}
Example #2
Source File: test_commands.py From sacred with MIT License | 6 votes |
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
Example #3
Source File: modular.py From sacred with MIT License | 5 votes |
def cfg1(): verbose = True # ============== Ingredient 1: dataset.paths =================
Example #4
Source File: modular.py From sacred with MIT License | 5 votes |
def cfg2(settings): v = not settings["verbose"] base = "/home/sacred/" # ============== Ingredient 2: dataset =======================
Example #5
Source File: ingredient.py From sacred with MIT License | 5 votes |
def cfg2(): filename = "foo.npy" # add the Ingredient while creating the experiment
Example #6
Source File: TaskBuilder.py From tape-neurips2019 with MIT License | 5 votes |
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)
Example #7
Source File: ModelBuilder.py From tape-neurips2019 with MIT License | 5 votes |
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)
Example #8
Source File: coco.py From keras-contrib with MIT License | 5 votes |
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 =======================