theanets.layers.recurrent.Bidirectional¶
-
class
theanets.layers.recurrent.
Bidirectional
(worker='rnn', **kwargs)[source]¶ 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)[source]¶ x.__init__(…) initializes x; see help(type(x)) for signature
Methods
__init__
([worker])x.__init__(…) initializes x; see help(type(x)) for signature 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. bind
(*args, **kwargs)Bind this layer into a computation graph. connect
(inputs)Create Theano variables representing the outputs of this layer. find
(key)Get a shared variable for a parameter by name. full_name
(name)Return a fully-scoped name for the given layer output. log
()Log some information about this layer. log_params
()Log information about this layer’s parameters. resolve_inputs
(layers)Resolve the names of inputs for this layer into shape tuples. resolve_outputs
()Resolve the names of outputs for this layer into shape tuples. 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_name
Name of layer input (for layers with one input). input_shape
Shape of layer input (for layers with one input). input_size
Size of layer input (for layers with one input). output_name
Full name of the default output for this layer. output_shape
Shape of default output from this layer. output_size
Number of “neurons” in this layer’s default output. params
-
bind
(*args, **kwargs)[source]¶ Bind this layer into a computation graph.
This method is a wrapper for performing common initialization tasks. It calls
resolve()
,setup()
, andlog()
.Parameters: - graph :
Network
A computation network in which this layer is to be bound.
- reset : bool, optional
If
True
(the default), reset the resolved layers for this layer.- initialize : bool, optional
If
True
(the default), initialize the parameters for this layer by callingsetup()
.
Raises: - theanets.util.ConfigurationError :
If an input cannot be resolved.
- graph :
-
to_spec
()[source]¶ Create a specification dictionary for this layer.
Returns: - spec : dict
A dictionary specifying the configuration of this layer.
-
transform
(inputs)[source]¶ 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
Layer.connect()
.
Returns: - output : Theano expression
The output for this layer is the same as the input.
- updates : list
An empty updates list.