neuralmonkey.experiment module

Provides a high-level API for training and using a model.

class neuralmonkey.experiment.Experiment(config_path: str, train_mode: bool = False, overwrite_output_dir: bool = False, config_changes: List[str] = None) → None

Bases: object

__init__(config_path: str, train_mode: bool = False, overwrite_output_dir: bool = False, config_changes: List[str] = None) → None

Initialize a Neural Monkey experiment.

Parameters:
  • config_path – The path to the experiment configuration file.
  • train_mode – Indicates whether the model should be prepared for training.
  • overwrite_output_dir – Indicates whether an existing experiment should be reused. If True, this overrides the setting in the configuration file.
  • config_changes – A list of modifications that will be made to the loaded configuration file before parsing.
build_model() → None
evaluate(dataset: neuralmonkey.dataset.dataset.Dataset, write_out: bool = False, batch_size: int = None, log_progress: int = 0) → Dict[str, Any]

Run the model on a given dataset and evaluate the outputs.

Parameters:
  • dataset – The dataset on which the model will be executed.
  • write_out – Flag whether the outputs should be printed to a file defined in the dataset object.
  • batch_size – size of the minibatch
  • log_progress – log progress every X seconds
Returns:

Dictionary of evaluation names and their values which includes the metrics applied on respective series loss and loss values from the run.

classmethod get_current() → neuralmonkey.experiment.Experiment

Return the experiment that is currently being built.

get_initializer(var_name: str, default: Callable = None) → Union[Callable, NoneType]

Return the initializer associated with the given variable name.

Calling the method marks the given initializer as used.

get_path(filename: str, cont_index: int = None) → str

Return the path to the most recent version of the given file.

load_variables(variable_files: List[str] = None) → None
model
run_model(dataset: neuralmonkey.dataset.dataset.Dataset, write_out: bool = False, batch_size: int = None, log_progress: int = 0) → Tuple[List[neuralmonkey.runners.base_runner.ExecutionResult], Dict[str, List[Any]]]

Run the model on a given dataset.

Parameters:
  • dataset – The dataset on which the model will be executed.
  • write_out – Flag whether the outputs should be printed to a file defined in the dataset object.
  • batch_size – size of the minibatch
  • log_progress – log progress every X seconds
Returns:

A list of `ExecutionResult`s and a dictionary of the output series.

train() → None
update_initializers(initializers: Iterable[Tuple[str, Callable]]) → None

Update the dictionary mapping variable names to initializers.

neuralmonkey.experiment.create_config(train_mode: bool = True) → neuralmonkey.config.configuration.Configuration
neuralmonkey.experiment.save_git_info(git_commit_file: str, git_diff_file: str, branch: str = 'HEAD', repo_dir: str = None) → None
neuralmonkey.experiment.visualize_embeddings(sequences: List[neuralmonkey.model.sequence.EmbeddedFactorSequence], output_dir: str) → None