neuralmonkey.model.gradient_blocking module

Module that blocks gradient propagation to model parts.

class neuralmonkey.model.gradient_blocking.SpatialStatefulView(blocked_object: neuralmonkey.model.stateful.SpatialStateful) → None

Bases: neuralmonkey.model.stateful.SpatialStateful

Provides a gradient-blocking view of a SpatialStateful object.

__init__(blocked_object: neuralmonkey.model.stateful.SpatialStateful) → None

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

dependencies

Return a list of attribute names regarded as dependents.

spatial_mask

Return mask for the spatial_states.

A 3D Tensor of shape (batch, width, height) of type float32 which masks the spatial states that they can be of different shapes. The mask should only contain ones or zeros.

spatial_states

Return object states in space.

A 4D Tensor of shape (batch, width, height, state_size) which contains the states of the object in space (e.g. final layer of a convolution network processing an image.

class neuralmonkey.model.gradient_blocking.StatefulView(blocked_object: neuralmonkey.model.stateful.Stateful) → None

Bases: neuralmonkey.model.stateful.Stateful

Provides a gradient-blocking view of a Stateful object.

__init__(blocked_object: neuralmonkey.model.stateful.Stateful) → None

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

dependencies

Return a list of attribute names regarded as dependents.

output

Return the object output.

A 2D Tensor of shape (batch, state_size) which contains the resulting state of the object.

class neuralmonkey.model.gradient_blocking.TemporalStatefulView(blocked_object: neuralmonkey.model.stateful.TemporalStateful) → None

Bases: neuralmonkey.model.stateful.TemporalStateful

Provides a gradient-blocking view of a TemporalStateful object.

__init__(blocked_object: neuralmonkey.model.stateful.TemporalStateful) → None

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

dependencies

Return a list of attribute names regarded as dependents.

temporal_mask

Return mask for the temporal_states.

A 2D Tensor of shape (batch, time) of type float32 which masks the temporal states so each sequence can have a different length. It should only contain ones or zeros.

temporal_states

Return object states in time.

A 3D Tensor of shape (batch, time, state_size) which contains the states of the object in time (e.g. hidden states of a recurrent encoder.