neuralmonkey.model.stateful module¶
Module that provides classes that encapsulate model parts with states.
There are three classes: Stateful, TemporalStateful, and SpatialStateful.
Model parts that do not keep states in time but have a single tensor on the output should be instances of Stateful. Model parts that keep their hidden states in a timeoriented list (e.g. recurrent encoder) should be instances of TemporalStateful. Model parts that keep the states in a 2D matrix (e.g. image encoders) should be instances of SpatialStateful.
There are also classes that inherit from both stateful and temporal or spatial stateful (e.g. TemporalStatefulWithOutput) that can be used for model parts that satisfy more requirements (e.g. recurrent encoder).

class
neuralmonkey.model.stateful.
SpatialStateful
¶ Bases:
object

dimension
¶ Return the dimension of the states.

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.stateful.
SpatialStatefulWithOutput
¶ Bases:
neuralmonkey.model.stateful.Stateful
,neuralmonkey.model.stateful.SpatialStateful

class
neuralmonkey.model.stateful.
Stateful
¶ Bases:
object

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


class
neuralmonkey.model.stateful.
TemporalStateful
¶ Bases:
object

dimension
¶ Return the dimension of the states.

lengths
¶ Return the sequence lengths.
A 1D Tensor of type int32 that stores the lengths of the state sequences in the batch.

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.


class
neuralmonkey.model.stateful.
TemporalStatefulWithOutput
¶ Bases:
neuralmonkey.model.stateful.Stateful
,neuralmonkey.model.stateful.TemporalStateful