GRU - 3 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. GRU3 → GRU7 +7 -6
GRU3 → GRU7 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
- - zt = f(Xt*(Wz^T) + Ht-1*(Rz^T) + Wbz + Rbz)
33
+ - zt = f(Xt*(Wz^T) + Ht-1*Rz + Wbz + Rbz)
34
- - rt = f(Xt*(Wr^T) + Ht-1*(Rr^T) + Wbr + Rbr)
34
+ - rt = f(Xt*(Wr^T) + Ht-1*Rr + Wbr + Rbr)
35
- - ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*(Rh^T) + Rbh + Wbh) # default, when linear_before_reset = 0
35
+ - ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*Rh + Rbh + Wbh) # default, when linear_before_reset = 0
36
- - ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*(Rh^T) + Rbh)) + Wbh) # when linear_before_reset != 0
36
+ - ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*Rh + Rbh) + Wbh) # when linear_before_reset != 0
37
37
  - Ht = (1 - zt) (.) ht + zt (.) Ht-1
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
38
  **Attributes**
40
39
  * **activation_alpha**:
41
40
  Optional scaling values used by some activation functions. The
42
41
  values are consumed in the order of activation functions, for
43
42
  example (f, g, h) in LSTM. Default values are the same as of
44
43
  corresponding ONNX operators.For example with LeakyRelu, the default
45
44
  alpha is 0.01.
46
45
  * **activation_beta**:
47
46
  Optional scaling values used by some activation functions. The
48
47
  values are consumed in the order of activation functions, for
49
48
  example (f, g, h) in LSTM. Default values are the same as of
50
49
  corresponding ONNX operators.
51
50
  * **activations**:
52
51
  A list of 2 (or 4 if bidirectional) activation functions for update,
53
52
  reset, and hidden gates. The activation functions must be one of the
54
53
  activation functions specified above. Optional: See the equations
55
54
  for default if not specified.
56
55
  * **clip**:
57
56
  Cell clip threshold. Clipping bounds the elements of a tensor in the
58
57
  range of [-threshold, +threshold] and is applied to the input of
59
58
  activations. No clip if not specified.
60
59
  * **direction**:
61
60
  Specify if the RNN is forward, reverse, or bidirectional. Must be
62
61
  one of forward (default), reverse, or bidirectional.
63
62
  * **hidden_size**:
64
63
  Number of neurons in the hidden layer
65
64
  * **linear_before_reset**:
66
65
  When computing the output of the hidden gate, apply the linear
67
66
  transformation before multiplying by the output of the reset gate.
67
+ * **output_sequence**:
68
+ The sequence output for the hidden is optional if 0. Default 0.
68
69
  **Inputs**
69
70
  Between 3 and 6 inputs.
70
71
  * **X** (heterogeneous) - **T**:
71
72
  The input sequences packed (and potentially padded) into one 3-D
72
73
  tensor with the shape of [seq_length, batch_size, input_size].
73
74
  * **W** (heterogeneous) - **T**:
74
75
  The weight tensor for the gates. Concatenation of W[zrh] and
75
76
  WB[zrh] (if bidirectional) along dimension 0. This tensor has
76
77
  shape [num_directions, 3*hidden_size, input_size].
77
78
  * **R** (heterogeneous) - **T**:
78
79
  The recurrence weight tensor. Concatenation of R[zrh] and
79
80
  RB[zrh] (if bidirectional) along dimension 0. This tensor has
80
81
  shape [num_directions, 3*hidden_size, hidden_size].
81
82
  * **B** (optional, heterogeneous) - **T**:
82
83
  The bias tensor for the gates. Concatenation of [Wb[zrh], Rb[zrh]]
83
84
  and [WBb[zrh], RBb[zrh]] (if bidirectional) along dimension 0.
84
85
  This tensor has shape [num_directions, 6*hidden_size]. Optional:
85
86
  If not specified - assumed to be 0
86
87
  * **sequence_lens** (optional, heterogeneous) - **T1**:
87
88
  Optional tensor specifying lengths of the sequences in a batch. If
88
89
  not specified - assumed all sequences in the batch to have length
89
90
  seq_length. It has shape [batch_size].
90
91
  * **initial_h** (optional, heterogeneous) - **T**:
91
92
  Optional initial value of the hidden. If not specified - assumed to
92
93
  be 0. It has shape [num_directions, batch_size, hidden_size].
93
94
  **Outputs**
94
95
  Between 0 and 2 outputs.
95
96
  * **Y** (optional, heterogeneous) - **T**:
96
97
  A tensor that concats all the intermediate output values of the
97
98
  hidden. It has shape [seq_length, num_directions, batch_size,
98
- hidden_size].
99
+ hidden_size]. It is optional if output_sequence is 0.
99
100
  * **Y_h** (optional, heterogeneous) - **T**:
100
101
  The last output value of the hidden. It has shape [num_directions,
101
102
  batch_size, hidden_size].
102
103
  **Type Constraints**
103
104
  * **T** in (
104
105
  tensor(double),
105
106
  tensor(float),
106
107
  tensor(float16)
107
108
  ):
108
109
  Constrain input and output types to float tensors.
109
110
  * **T1** in (
110
111
  tensor(int32)
111
112
  ):
112
113
  Constrain seq_lens to integer tensor.