LSTM - 1 vs 7

Next section compares an older to a newer version of the same operator after both definition are converted into markdown text. Green means an addition to the newer version, red means a deletion. Anything else is unchanged.

Files changed (1) hide show
  1. LSTM1 → LSTM7 +7 -10
LSTM1 → LSTM7 RENAMED
@@ -1 +1 @@
1
1
  Computes an one-layer LSTM. This operator is usually supported via some
2
2
  custom implementation such as CuDNN.
3
3
  Notations:
4
4
  X - input tensor
5
5
  i - input gate
6
6
  o - output gate
7
7
  f - forget gate
8
8
  c - cell gate
9
9
  t - time step (t-1 means previous time step)
10
10
  W[iofc] - W parameter weight matrix for input, output, forget, and cell gates
11
11
  R[iofc] - R recurrence weight matrix for input, output, forget, and cell gates
12
12
  Wb[iofc] - W bias vectors for input, output, forget, and cell gates
13
13
  Rb[iofc] - R bias vectors for input, output, forget, and cell gates
14
14
  P[iof] - P peephole weight vector for input, output, and forget gates
15
15
  WB[iofc] - W parameter weight matrix for backward input, output, forget, and cell gates
16
16
  RB[iofc] - R recurrence weight matrix for backward input, output, forget, and cell gates
17
17
  WBb[iofc] - W bias vectors for backward input, output, forget, and cell gates
18
18
  RBb[iofc] - R bias vectors for backward input, output, forget, and cell gates
19
19
  PB[iof] - P peephole weight vector for backward input, output, and forget gates
20
20
  H - Hidden state
21
21
  num_directions - 2 if direction == bidirectional else 1
22
22
  Activation functions:
23
23
  Relu(x) - max(0, x)
24
24
  Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})
25
25
  Sigmoid(x) - 1/(1 + e^{-x})
26
26
  (NOTE: Below are optional)
27
27
  Affine(x) - alpha*x + beta
28
28
  LeakyRelu(x) - x if x >= 0 else alpha * x
29
29
  ThresholdedRelu(x) - x if x >= alpha else 0
30
30
  ScaledTanh(x) - alpha*Tanh(beta*x)
31
31
  HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)
32
32
  Elu(x) - x if x >= 0 else alpha*(e^x - 1)
33
33
  Softsign(x) - x/(1 + |x|)
34
34
  Softplus(x) - log(1 + e^x)
35
35
  Equations (Default: f=Sigmoid, g=Tanh, h=Tanh):
36
- - it = f(Xt*(Wi^T) + Ht-1*Ri + Pi (.) Ct-1 + Wbi + Rbi)
36
+ - it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Pi (.) Ct-1 + Wbi + Rbi)
37
- - ft = f(Xt*(Wf^T) + Ht-1*Rf + Pf (.) Ct-1 + Wbf + Rbf)
37
+ - ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Pf (.) Ct-1 + Wbf + Rbf)
38
- - ct = g(Xt*(Wc^T) + Ht-1*Rc + Wbc + Rbc)
38
+ - ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc)
39
39
  - Ct = ft (.) Ct-1 + it (.) ct
40
- - ot = f(Xt*(Wo^T) + Ht-1*Ro + Po (.) Ct + Wbo + Rbo)
40
+ - ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Po (.) Ct + Wbo + Rbo)
41
41
  - Ht = ot (.) h(Ct)
42
+ This operator has **optional** inputs/outputs. See [ONNX IR](https://github.com/onnx/onnx/blob/main/docs/IR.md) for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.
42
43
  ### Attributes
43
44
  * **activation_alpha - FLOATS** :
44
45
  Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
45
46
  * **activation_beta - FLOATS** :
46
47
  Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
47
48
  * **activations - STRINGS** :
48
49
  A list of 3 (or 6 if bidirectional) activation functions for input, output, forget, cell, and hidden. The activation functions must be one of the activation functions specified above. Optional: See the equations for default if not specified.
49
50
  * **clip - FLOAT** :
50
51
  Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
51
52
  * **direction - STRING** (default is 'forward'):
52
53
  Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
53
54
  * **hidden_size - INT** :
54
55
  Number of neurons in the hidden layer
55
56
  * **input_forget - INT** (default is '0'):
56
- Couple the input and forget gates if 1, default 0.
57
+ Couple the input and forget gates if 1.
57
-
58
- * **output_sequence - INT** (default is '0'):
59
-
60
- The sequence output for the hidden is optional if 0. Default 0.
61
58
  ### Inputs
62
59
  Between 3 and 8 inputs.
63
60
  - **X** (heterogeneous) - **T**:
64
61
  The input sequences packed (and potentially padded) into one 3-D tensor with the shape of [seq_length, batch_size, input_size].
65
62
  - **W** (heterogeneous) - **T**:
66
63
  The weight tensor for the gates. Concatenation of W[iofc] and WB[iofc] (if bidirectional) along dimension 0. The tensor has shape [num_directions, 4*hidden_size, input_size].
67
64
  - **R** (heterogeneous) - **T**:
68
65
  The recurrence weight tensor. Concatenation of R[iofc] and RB[iofc] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 4*hidden_size, hidden_size].
69
66
  - **B** (optional, heterogeneous) - **T**:
70
67
  The bias tensor for input gate. Concatenation of [Wb[iofc], Rb[iofc]], and [WBb[iofc], RBb[iofc]] (if bidirectional) along dimension 0. This tensor has shape [num_directions, 8*hidden_size]. Optional: If not specified - assumed to be 0.
71
68
  - **sequence_lens** (optional, heterogeneous) - **T1**:
72
69
  Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length seq_length. It has shape [batch_size].
73
70
  - **initial_h** (optional, heterogeneous) - **T**:
74
71
  Optional initial value of the hidden. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].
75
72
  - **initial_c** (optional, heterogeneous) - **T**:
76
73
  Optional initial value of the cell. If not specified - assumed to be 0. It has shape [num_directions, batch_size, hidden_size].
77
74
  - **P** (optional, heterogeneous) - **T**:
78
75
  The weight tensor for peepholes. Concatenation of P[iof] and PB[iof] (if bidirectional) along dimension 0. It has shape [num_directions, 3*hidde_size]. Optional: If not specified - assumed to be 0.
79
76
  ### Outputs
80
77
  Between 0 and 3 outputs.
81
78
  - **Y** (optional, heterogeneous) - **T**:
82
- A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size]. It is optional if output_sequence is 0.
79
+ A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size].
83
80
  - **Y_h** (optional, heterogeneous) - **T**:
84
81
  The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size].
85
82
  - **Y_c** (optional, heterogeneous) - **T**:
86
83
  The last output value of the cell. It has shape [num_directions, batch_size, hidden_size].
87
84
  ### Type Constraints
88
85
  * **T** in ( tensor(double), tensor(float), tensor(float16) ):
89
86
  Constrain input and output types to float tensors.
90
87
  * **T1** in ( tensor(int32) ):
91
88
  Constrain seq_lens to integer tensor.