RNN - 7 vs 14#

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. RNN7 → RNN14 +0 -10
RNN7 → RNN14 RENAMED
@@ -1 +1 @@
1
1
  Computes an one-layer simple RNN. This operator is usually supported
2
2
  via some custom implementation such as CuDNN.
3
3
  Notations:
4
4
  X - input tensor
5
5
  i - input gate
6
6
  t - time step (t-1 means previous time step)
7
7
  Wi - W parameter weight matrix for input gate
8
8
  Ri - R recurrence weight matrix for input gate
9
9
  Wbi - W parameter bias vector for input gate
10
10
  Rbi - R parameter bias vector for input gate
11
11
  WBi - W parameter weight matrix for backward input gate
12
12
  RBi - R recurrence weight matrix for backward input gate
13
13
  WBbi - WR bias vectors for backward input gate
14
14
  RBbi - RR bias vectors for backward input gate
15
15
  H - Hidden state
16
16
  num_directions - 2 if direction == bidirectional else 1
17
17
  Activation functions:
18
18
  Relu(x) - max(0, x)
19
19
  Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})
20
20
  Sigmoid(x) - 1/(1 + e^{-x})
21
21
  (NOTE: Below are optional)
22
22
  Affine(x) - alpha*x + beta
23
23
  LeakyRelu(x) - x if x >= 0 else alpha * x
24
24
  ThresholdedRelu(x) - x if x >= alpha else 0
25
25
  ScaledTanh(x) - alpha*Tanh(beta*x)
26
26
  HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)
27
27
  Elu(x) - x if x >= 0 else alpha*(e^x - 1)
28
28
  Softsign(x) - x/(1 + |x|)
29
29
  Softplus(x) - log(1 + e^x)
30
30
  Equations (Default: f=Tanh):
31
31
  - Ht = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi)
32
32
  This operator has **optional** inputs/outputs. See ONNX <https://github.com/onnx/onnx/blob/master/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.
33
33
  **Attributes**
34
34
  * **activation_alpha**:
35
35
  Optional scaling values used by some activation functions. The
36
36
  values are consumed in the order of activation functions, for
37
37
  example (f, g, h) in LSTM. Default values are the same as of
38
38
  corresponding ONNX operators.For example with LeakyRelu, the default
39
39
  alpha is 0.01.
40
40
  * **activation_beta**:
41
41
  Optional scaling values used by some activation functions. The
42
42
  values are consumed in the order of activation functions, for
43
43
  example (f, g, h) in LSTM. Default values are the same as of
44
44
  corresponding ONNX operators.
45
45
  * **activations**:
46
46
  One (or two if bidirectional) activation function for input gate.
47
47
  The activation function must be one of the activation functions
48
48
  specified above. Optional: Default Tanh if not specified.
49
49
  * **clip**:
50
50
  Cell clip threshold. Clipping bounds the elements of a tensor in the
51
51
  range of [-threshold, +threshold] and is applied to the input of
52
52
  activations. No clip if not specified.
53
53
  * **direction**:
54
54
  Specify if the RNN is forward, reverse, or bidirectional. Must be
55
55
  one of forward (default), reverse, or bidirectional.
56
56
  * **hidden_size**:
57
57
  Number of neurons in the hidden layer
58
- * **layout**:
59
- The shape format of inputs X, initial_h and outputs Y, Y_h. If 0,
60
- the following shapes are expected: X.shape = [seq_length,
61
- batch_size, input_size], Y.shape = [seq_length, num_directions,
62
- batch_size, hidden_size], initial_h.shape = Y_h.shape =
63
- [num_directions, batch_size, hidden_size]. If 1, the following
64
- shapes are expected: X.shape = [batch_size, seq_length, input_size],
65
- Y.shape = [batch_size, seq_length, num_directions, hidden_size],
66
- initial_h.shape = Y_h.shape = [batch_size, num_directions,
67
- hidden_size].
68
58
  **Inputs**
69
59
  Between 3 and 6 inputs.
70
60
  * **X** (heterogeneous) - **T**:
71
61
  The input sequences packed (and potentially padded) into one 3-D
72
62
  tensor with the shape of [seq_length, batch_size, input_size].
73
63
  * **W** (heterogeneous) - **T**:
74
64
  The weight tensor for input gate. Concatenation of Wi and WBi
75
65
  (if bidirectional). The tensor has shape [num_directions,
76
66
  hidden_size, input_size].
77
67
  * **R** (heterogeneous) - **T**:
78
68
  The recurrence weight tensor. Concatenation of Ri and RBi (if
79
69
  bidirectional). The tensor has shape [num_directions, hidden_size,
80
70
  hidden_size].
81
71
  * **B** (optional, heterogeneous) - **T**:
82
72
  The bias tensor for input gate. Concatenation of [Wbi, Rbi] and
83
73
  [WBbi, RBbi] (if bidirectional). The tensor has shape
84
74
  [num_directions, 2*hidden_size]. Optional: If not specified -
85
75
  assumed to be 0.
86
76
  * **sequence_lens** (optional, heterogeneous) - **T1**:
87
77
  Optional tensor specifying lengths of the sequences in a batch. If
88
78
  not specified - assumed all sequences in the batch to have length
89
79
  seq_length. It has shape [batch_size].
90
80
  * **initial_h** (optional, heterogeneous) - **T**:
91
81
  Optional initial value of the hidden. If not specified - assumed to
92
82
  be 0. It has shape [num_directions, batch_size, hidden_size].
93
83
  **Outputs**
94
84
  Between 0 and 2 outputs.
95
85
  * **Y** (optional, heterogeneous) - **T**:
96
86
  A tensor that concats all the intermediate output values of the
97
87
  hidden. It has shape [seq_length, num_directions, batch_size,
98
88
  hidden_size].
99
89
  * **Y_h** (optional, heterogeneous) - **T**:
100
90
  The last output value of the hidden. It has shape [num_directions,
101
91
  batch_size, hidden_size].
102
92
  **Type Constraints**
103
93
  * **T** in (
104
94
  tensor(double),
105
95
  tensor(float),
106
96
  tensor(float16)
107
97
  ):
108
98
  Constrain input and output types to float tensors.
109
99
  * **T1** in (
110
100
  tensor(int32)
111
101
  ):
112
102
  Constrain seq_lens to integer tensor.