neuralmonkey.runners.base_runner module

class neuralmonkey.runners.base_runner.BaseRunner(output_series: str, decoder: MP) → None

Bases: neuralmonkey.runners.base_runner.GraphExecutor, typing.Generic

Base class for runners.

Runners are graph executors that retrieve tensors from the model without changing the model parameters. Each runner has a top-level model part it relates to.

class Executable(executor: Executor, compute_losses: bool, summaries: bool, num_sessions: int) → None

Bases: neuralmonkey.runners.base_runner.Executable

next_to_execute() → Tuple[Union[Dict, List], List[Dict[tensorflow.python.framework.ops.Tensor, Union[int, float, numpy.ndarray]]]]

Get the tensors and additional feed dicts for execution.

__init__(output_series: str, decoder: MP) → None

Initialize self. See help(type(self)) for accurate signature.

decoder_data_id
loss_names
class neuralmonkey.runners.base_runner.ExecutionResult

Bases: neuralmonkey.runners.base_runner.ExecutionResult

A data structure that represents the result of a graph execution.

The goal of each runner is to populate this structure and set it as its self._result.

outputs

A batch of outputs of the runner.

losses

A (possibly empty) list of loss values computed during the run.

scalar_summaries

A TensorFlow summary object with scalar values.

histogram_summaries

A TensorFlow summary object with histograms.

image_summaries

A TensorFlow summary object with images.

class neuralmonkey.runners.base_runner.GraphExecutor(dependencies: Set[neuralmonkey.model.model_part.GenericModelPart]) → None

Bases: neuralmonkey.model.model_part.GenericModelPart

The abstract parent class of all graph executors.

In Neural Monkey, a graph executor is an object that retrieves tensors from the computational graph. The two major groups of graph executors are trainers and runners.

Each graph executor is an instance of GenericModelPart class, which means it has parameterized and feedable dependencies which reference the model part objects needed to be created in order to compute the tensors of interest (called “fetches”).

Every graph executor has a method called get_executable, which returns an GraphExecutor.Executable instance, which specifies what tensors to execute and collects results from the session execution.

class Executable(executor: Executor, compute_losses: bool, summaries: bool, num_sessions: int) → None

Bases: typing.Generic

Abstract base class for executables.

Executables are objects associated with the graph executors. Each executable has two main functions: next_to_execute and collect_results. These functions are called in a loop, until the executable’s result has been set.

To make use of Mypy’s type checking, the executables are generic and are parameterized by the type of their graph executor. Since Python does not know the concept of nested classes, each executable receives the instance of the graph executor through its constructor.

When subclassing GraphExecutor, it is also necessary to subclass the Executable class and name it Executable, so it overrides the definition of this class. Following this guideline, the default implementation of the get_executable function on the graph executor will work without the need of overriding it.

__init__(executor: Executor, compute_losses: bool, summaries: bool, num_sessions: int) → None

Initialize self. See help(type(self)) for accurate signature.

collect_results(results: List[Dict]) → None
executor
next_to_execute() → Tuple[Union[Dict, List], List[Dict[tensorflow.python.framework.ops.Tensor, Union[int, float, numpy.ndarray]]]]

Get the tensors and additional feed dicts for execution.

result
set_result(outputs: List[Any], losses: List[float], scalar_summaries: tensorflow.core.framework.summary_pb2.Summary, histogram_summaries: tensorflow.core.framework.summary_pb2.Summary, image_summaries: tensorflow.core.framework.summary_pb2.Summary) → None
__init__(dependencies: Set[neuralmonkey.model.model_part.GenericModelPart]) → None

Initialize self. See help(type(self)) for accurate signature.

dependencies

Return a list of attribute names regarded as dependents.

feedables
fetches
get_executable(compute_losses: bool, summaries: bool, num_sessions: int) → neuralmonkey.runners.base_runner.GraphExecutor.Executable
parameterizeds
neuralmonkey.runners.base_runner.reduce_execution_results(execution_results: List[neuralmonkey.runners.base_runner.ExecutionResult]) → neuralmonkey.runners.base_runner.ExecutionResult

Aggregate execution results into one.