GRU - 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. GRU7 → GRU14 +0 -10
GRU7 → GRU14 RENAMED
@@ -1 +1 @@
1
1
  Computes an one-layer GRU. This operator is usually supported via some custom
2
2
  implementation such as CuDNN.
3
3
  Notations:
4
4
  X - input tensor
5
5
  z - update gate
6
6
  r - reset gate
7
7
  h - hidden gate
8
8
  t - time step (t-1 means previous time step)
9
9
  W[zrh] - W parameter weight matrix for update, reset, and hidden gates
10
10
  R[zrh] - R recurrence weight matrix for update, reset, and hidden gates
11
11
  Wb[zrh] - W bias vectors for update, reset, and hidden gates
12
12
  Rb[zrh] - R bias vectors for update, reset, and hidden gates
13
13
  WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates
14
14
  RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates
15
15
  WBb[zrh] - W bias vectors for backward update, reset, and hidden gates
16
16
  RBb[zrh] - R bias vectors for backward update, reset, and hidden gates
17
17
  H - Hidden state
18
18
  num_directions - 2 if direction == bidirectional else 1
19
19
  Activation functions:
20
20
  Relu(x) - max(0, x)
21
21
  Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x})
22
22
  Sigmoid(x) - 1/(1 + e^{-x})
23
23
  (NOTE: Below are optional)
24
24
  Affine(x) - alpha*x + beta
25
25
  LeakyRelu(x) - x if x >= 0 else alpha * x
26
26
  ThresholdedRelu(x) - x if x >= alpha else 0
27
27
  ScaledTanh(x) - alpha*Tanh(beta*x)
28
28
  HardSigmoid(x) - min(max(alpha*x + beta, 0), 1)
29
29
  Elu(x) - x if x >= 0 else alpha*(e^x - 1)
30
30
  Softsign(x) - x/(1 + |x|)
31
31
  Softplus(x) - log(1 + e^x)
32
32
  Equations (Default: f=Sigmoid, g=Tanh):
33
33
  - zt = f(Xt*(Wz^T) + Ht-1*(Rz^T) + Wbz + Rbz)
34
34
  - rt = f(Xt*(Wr^T) + Ht-1*(Rr^T) + Wbr + Rbr)
35
35
  - ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*(Rh^T) + Rbh + Wbh) # default, when linear_before_reset = 0
36
36
  - ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*(Rh^T) + Rbh)) + Wbh) # when linear_before_reset != 0
37
37
  - Ht = (1 - zt) (.) ht + zt (.) Ht-1
38
38
  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.
39
39
  **Attributes**
40
40
  * **activation_alpha**:
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.For example with LeakyRelu, the default
45
45
  alpha is 0.01.
46
46
  * **activation_beta**:
47
47
  Optional scaling values used by some activation functions. The
48
48
  values are consumed in the order of activation functions, for
49
49
  example (f, g, h) in LSTM. Default values are the same as of
50
50
  corresponding ONNX operators.
51
51
  * **activations**:
52
52
  A list of 2 (or 4 if bidirectional) activation functions for update,
53
53
  reset, and hidden gates. The activation functions must be one of the
54
54
  activation functions specified above. Optional: See the equations
55
55
  for default if not specified.
56
56
  * **clip**:
57
57
  Cell clip threshold. Clipping bounds the elements of a tensor in the
58
58
  range of [-threshold, +threshold] and is applied to the input of
59
59
  activations. No clip if not specified.
60
60
  * **direction**:
61
61
  Specify if the RNN is forward, reverse, or bidirectional. Must be
62
62
  one of forward (default), reverse, or bidirectional.
63
63
  * **hidden_size**:
64
64
  Number of neurons in the hidden layer
65
- * **layout**:
66
- The shape format of inputs X, initial_h and outputs Y, Y_h. If 0,
67
- the following shapes are expected: X.shape = [seq_length,
68
- batch_size, input_size], Y.shape = [seq_length, num_directions,
69
- batch_size, hidden_size], initial_h.shape = Y_h.shape =
70
- [num_directions, batch_size, hidden_size]. If 1, the following
71
- shapes are expected: X.shape = [batch_size, seq_length, input_size],
72
- Y.shape = [batch_size, seq_length, num_directions, hidden_size],
73
- initial_h.shape = Y_h.shape = [batch_size, num_directions,
74
- hidden_size].
75
65
  * **linear_before_reset**:
76
66
  When computing the output of the hidden gate, apply the linear
77
67
  transformation before multiplying by the output of the reset gate.
78
68
  **Inputs**
79
69
  Between 3 and 6 inputs.
80
70
  * **X** (heterogeneous) - **T**:
81
71
  The input sequences packed (and potentially padded) into one 3-D
82
72
  tensor with the shape of [seq_length, batch_size, input_size].
83
73
  * **W** (heterogeneous) - **T**:
84
74
  The weight tensor for the gates. Concatenation of W[zrh] and
85
75
  WB[zrh] (if bidirectional) along dimension 0. This tensor has
86
76
  shape [num_directions, 3*hidden_size, input_size].
87
77
  * **R** (heterogeneous) - **T**:
88
78
  The recurrence weight tensor. Concatenation of R[zrh] and
89
79
  RB[zrh] (if bidirectional) along dimension 0. This tensor has
90
80
  shape [num_directions, 3*hidden_size, hidden_size].
91
81
  * **B** (optional, heterogeneous) - **T**:
92
82
  The bias tensor for the gates. Concatenation of [Wb[zrh], Rb[zrh]]
93
83
  and [WBb[zrh], RBb[zrh]] (if bidirectional) along dimension 0.
94
84
  This tensor has shape [num_directions, 6*hidden_size]. Optional:
95
85
  If not specified - assumed to be 0
96
86
  * **sequence_lens** (optional, heterogeneous) - **T1**:
97
87
  Optional tensor specifying lengths of the sequences in a batch. If
98
88
  not specified - assumed all sequences in the batch to have length
99
89
  seq_length. It has shape [batch_size].
100
90
  * **initial_h** (optional, heterogeneous) - **T**:
101
91
  Optional initial value of the hidden. If not specified - assumed to
102
92
  be 0. It has shape [num_directions, batch_size, hidden_size].
103
93
  **Outputs**
104
94
  Between 0 and 2 outputs.
105
95
  * **Y** (optional, heterogeneous) - **T**:
106
96
  A tensor that concats all the intermediate output values of the
107
97
  hidden. It has shape [seq_length, num_directions, batch_size,
108
98
  hidden_size].
109
99
  * **Y_h** (optional, heterogeneous) - **T**:
110
100
  The last output value of the hidden. It has shape [num_directions,
111
101
  batch_size, hidden_size].
112
102
  **Type Constraints**
113
103
  * **T** in (
114
104
  tensor(double),
115
105
  tensor(float),
116
106
  tensor(float16)
117
107
  ):
118
108
  Constrain input and output types to float tensors.
119
109
  * **T1** in (
120
110
  tensor(int32)
121
111
  ):
122
112
  Constrain seq_lens to integer tensor.