Class ov::op::v4::LSTMCell#
-
class LSTMCell : public ov::op::util::RNNCellBase#
Class for single lstm cell node.
See also
LSTMSequence, RNNCell, GRUCell
Note
Following implementation supports:
peepholes
Gers & Schmidhuber (2000) https://ieeexplore.ieee.org/document/861302Coupling input and forget gates.
Note
It calculates following equations:
it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi) ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Wbf + Rbf) ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc) Ct = ft (.) Ct-1 + it (.) ct ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Wbo + Rbo) Ht = ot (.) h(Ct) * - Is a dot product, (.) - is a Hadamard product (element-wise), f, g, h - are activation functions.
Note
This class represents only single cell (for current time step) and not the whole LSTM Sequence layer
Public Functions
-
LSTMCell(const Output<Node> &X, const Output<Node> &initial_hidden_state, const Output<Node> &initial_cell_state, const Output<Node> &W, const Output<Node> &R, std::size_t hidden_size, const std::vector<std::string> &activations = std::vector<std::string>{"sigmoid", "tanh", "tanh"}, const std::vector<float> &activations_alpha = {}, const std::vector<float> &activations_beta = {}, float clip = 0.f)#
Constructs LSTMCell node.
- Parameters:
X – [in] The input tensor with shape: [batch_size, input_size].
initial_hidden_state – [in] The hidden state tensor at current time step with shape: [batch_size, hidden_size].
initial_cell_state – [in] The cell state tensor at current time step with shape: [batch_size, hidden_size].
W – [in] The gate weights tensor with shape: [4*hidden_size, input_size].
R – [in] The recurrence weights tensor with shape: [4*hidden_size, hidden_size].
hidden_size – [in] The number of hidden units for recurrent cell.
activations – [in] The vector of activation functions used inside recurrent cell.
activations_alpha – [in] The vector of alpha parameters for activation functions in order respective to activation list.
activations_beta – [in] The vector of beta parameters for activation functions in order respective to activation list.
clip – [in] The value defining clipping range [-clip, clip] on input of activation functions.
-
LSTMCell(const Output<Node> &X, const Output<Node> &initial_hidden_state, const Output<Node> &initial_cell_state, const Output<Node> &W, const Output<Node> &R, const Output<Node> &B, std::size_t hidden_size, const std::vector<std::string> &activations = std::vector<std::string>{"sigmoid", "tanh", "tanh"}, const std::vector<float> &activations_alpha = {}, const std::vector<float> &activations_beta = {}, float clip = 0.f)#
Constructs LSTMCell node.
- Parameters:
X – [in] The input tensor with shape: [batch_size, input_size].
initial_hidden_state – [in] The hidden state tensor at current time step with shape: [batch_size, hidden_size].
initial_cell_state – [in] The cell state tensor at current time step with shape: [batch_size, hidden_size].
W – [in] The weight tensor with shape: [4*hidden_size, input_size].
R – [in] The recurrence weight tensor with shape: [4*hidden_size, hidden_size].
B – [in] The bias tensor for gates with shape: [4*hidden_size].
hidden_size – [in] The number of hidden units for recurrent cell.
activations – [in] The vector of activation functions used inside recurrent cell.
activations_alpha – [in] The vector of alpha parameters for activation functions in order respective to activation list.
activations_beta – [in] The vector of beta parameters for activation functions in order respective to activation list.
clip – [in] The value defining clipping range [-clip, clip] on input of activation functions.
-
virtual void validate_and_infer_types() override#
Verifies that attributes and inputs are consistent and computes output shapes and element types. Must be implemented by concrete child classes so that it can be run any number of times.
Throws if the node is invalid.