neuralmonkey.model.parameterized module

class neuralmonkey.model.parameterized.Parameterized(name: str, reuse: Union[neuralmonkey.model.parameterized.Parameterized, NoneType] = None, save_checkpoint: str = None, load_checkpoint: str = None, initializers: List[Tuple[str, Callable]] = None) → None

Bases: object

Base class for parameterized model parts.

This class is an abstraction for all model parts which use TensorFlow variables. Shared properties and characteristics of all these objects are the capability of loading and saving the variables, re-using variables from a different Parameterized object, and managing variable scopes, including overriding the default initializer settings for the variables.

__init__(name: str, reuse: Union[neuralmonkey.model.parameterized.Parameterized, NoneType] = None, save_checkpoint: str = None, load_checkpoint: str = None, initializers: List[Tuple[str, Callable]] = None) → None

Construct a new parameterized object.

Parameters:
  • name – The name for the model part. Will be used in the variable and name scopes.
  • reuse – Optional parameterized part with which to share parameters.
  • save_checkpoint – Optional path to a checkpoint file which will store the parameters of this object.
  • load_checkpoint – Optional path to a checkpoint file from which to load initial variables for this object.
  • initializers – An InitializerSpecs instance with specification of the initializers.
load(session: tensorflow.python.client.session.Session) → None

Load model part from a checkpoint file.

name

Get the name of the parameterized object and its variable scope.

save(session: tensorflow.python.client.session.Session) → None

Save model part to a checkpoint file.

use_scope() → Iterator[NoneType]

Return the object variable scope context manager.

Return the context manager that (re)opens variable and name scopes of the parameterized object..