theanets.layers.recurrent.Bidirectional

class theanets.layers.recurrent.Bidirectional(worker='rnn', **kwargs)

A bidirectional recurrent layer runs worker models forward and backward.

Parameters:

worker : str, optional

This string specifies the type of worker layer to use for the forward and backward processing. This parameter defaults to ‘rnn’ (i.e., vanilla recurrent network layer), but can be given as any string that specifies a recurrent layer type.

Notes

The size of this layer is split in half, with each half allocated to a “worker” layer that processes data in one direction in time. The outputs of the forward and backward passes are concatenated into the overall output for the layer.

For an example specification of a bidirectional recurrent network, see [Gra13b].

References

[Gra13b](1, 2) A. Graves, N. Jaitly, & A. Mohamed. (2013) “Hybrid Speech Recognition with Deep Bidirectional LSTM.” http://www.cs.toronto.edu/~graves/asru_2013.pdf

Attributes

worker (str) The form of the underlying worker networks.
forward (theanets.layers.base.Layer) The layer that processes input data forwards in time.
backward (theanets.layers.base.Layer) The layer that processes input data backwards in time.
__init__(worker='rnn', **kwargs)

Methods

__init__([worker])
add_bias(name, size[, mean, std]) Helper method to create a new bias vector.
add_weights(name, nin, nout[, mean, std, ...]) Helper method to create a new weight matrix.
connect(inputs) Create Theano variables representing the outputs of this layer.
find(key) Get a shared variable for a parameter by name.
log() Log some information about this layer.
output_name([name]) Return a fully-scoped name for the given layer output.
setup() Set up the parameters and initial values for this layer.
to_spec() Create a specification dictionary for this layer.
transform(inputs) Transform the inputs for this layer into an output for the layer.

Attributes

input_size For networks with one input, get the input size.
num_params Total number of learnable parameters in this layer.
params A list of all learnable parameters in this layer.
num_params

Total number of learnable parameters in this layer.

params

A list of all learnable parameters in this layer.

to_spec()

Create a specification dictionary for this layer.

Returns:

spec : dict

A dictionary specifying the configuration of this layer.

transform(inputs)

Transform the inputs for this layer into an output for the layer.

Parameters:

inputs : dict of theano expressions

Symbolic inputs to this layer, given as a dictionary mapping string names to Theano expressions. See base.Layer.connect().

Returns:

outputs : dict of theano expressions

Theano expressions representing the output from the layer. This layer type produces an “out” output that concatenates the outputs from its underlying workers. If present, it also concatenates the “pre” and “cell” outputs from the underlying workers. Finally, it passes along the individual outputs from its workers using “fw” and “bw” prefixes for forward and backward directions.

updates : list of update pairs

A list of state updates to apply inside a theano function.