pub struct BiDirectionalLstmLayerParams {
pub input_vector_size: u64,
pub output_vector_size: u64,
pub activations_forward_lstm: Vec<ActivationParams>,
pub activations_backward_lstm: Vec<ActivationParams>,
pub params: Option<LstmParams>,
pub weight_params: Vec<LstmWeightParams>,
}Expand description
Bidirectional long short-term memory (LSTM) layer
.. code::
(y_t, c_t, y_t_reverse, c_t_reverse) = BiDirectionalLSTMLayer(x_t, y_{t-1}, c_{t-1}, y_{t-1}_reverse, c_{t-1}_reverse)Input
A blob of rank 5, with shape `[Seq, Batch, inputVectorSize, 1, 1]. This represents a sequence of vectors of size inputVectorSize. Output Same rank as the input. Represents a vector of size 2 * outputVectorSize``. It is either the final output or a sequence of outputs at all time steps.
- Output Shape:
\[1, Batch, 2 * outputVectorSize, 1, 1\], ifsequenceOutput == false - Output Shape:
\[Seq, Batch, 2 * outputVectorSize, 1, 1\], ifsequenceOutput == true
The first LSTM operates on the input sequence in the forward direction. The second LSTM operates on the input sequence in the reverse direction.
Example: given the input sequence \[x_1, x_2, x_3\],
where x_i are vectors at time index i:
The forward LSTM output is \[yf_1, yf_2, yf_3\],
where yf_i are vectors of size outputVectorSize:
yf_1is the output at the end of sequence {x_1}yf_2is the output at the end of sequence {x_1,x_2}yf_3is the output at the end of sequence {x_1,x_2,x_3}
The backward LSTM output: \[yb_1, yb_2, yb_3\],
where yb_i are vectors of size outputVectorSize:
yb_1is the output at the end of sequence {x_3}yb_2is the output at the end of sequence {x_3,x_2}yb_3is the output at the end of sequence {x_3,x_2,x_1}
Output of the bi-dir layer:
- if
sequenceOutput = True: {\[yf_1, yb_3\],\[yf_2, yb_2\],\[yf_3, yb_1\]} - if
sequenceOutput = False: {\[yf_3, yb_3\]}
Fields§
§input_vector_size: u64Size of the input vectors.
output_vector_size: u64Size of the outputs vectors. It is same for both forward and backward LSTMs.
activations_forward_lstm: Vec<ActivationParams>3 element array representing activations [f(),g(),h()] in that order. Typical values used = [sigmoid, tanh, tanh]. Activations supported are Linear, Sigmoid, Tanh, ReLU, Scaled Tanh (alpha = 1.71, beta = 2/3), Hard sigmoid (alpha = 0.2, beta = 0.5)
activations_backward_lstm: Vec<ActivationParams>Currently, backward LSTM activations must be same as the ones for the forward LSTM.
params: Option<LstmParams>Common parameters shared by the forward and backward LSTMs.
weight_params: Vec<LstmWeightParams>Weights and biases. Must be a length 2 message, for the forward and backward LSTM respectively.
Trait Implementations§
Source§impl Clone for BiDirectionalLstmLayerParams
impl Clone for BiDirectionalLstmLayerParams
Source§fn clone(&self) -> BiDirectionalLstmLayerParams
fn clone(&self) -> BiDirectionalLstmLayerParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BiDirectionalLstmLayerParams
impl Debug for BiDirectionalLstmLayerParams
Source§impl Message for BiDirectionalLstmLayerParams
impl Message for BiDirectionalLstmLayerParams
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.Source§impl PartialEq for BiDirectionalLstmLayerParams
impl PartialEq for BiDirectionalLstmLayerParams
Source§fn eq(&self, other: &BiDirectionalLstmLayerParams) -> bool
fn eq(&self, other: &BiDirectionalLstmLayerParams) -> bool
self and other values to be equal, and is used by ==.