RNN - 7 vs 14

Files changed (1) hide show
  1. RNN7 → RNN14 +10 -0
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].
58
68
  **Inputs**
59
69
  Between 3 and 6 inputs.
60
70
  * **X** (heterogeneous) - **T**:
61
71
  The input sequences packed (and potentially padded) into one 3-D
62
72
  tensor with the shape of [seq_length, batch_size, input_size].
63
73
  * **W** (heterogeneous) - **T**:
64
74
  The weight tensor for input gate. Concatenation of Wi and WBi
65
75
  (if bidirectional). The tensor has shape [num_directions,
66
76
  hidden_size, input_size].
67
77
  * **R** (heterogeneous) - **T**:
68
78
  The recurrence weight tensor. Concatenation of Ri and RBi (if
69
79
  bidirectional). The tensor has shape [num_directions, hidden_size,
70
80
  hidden_size].
71
81
  * **B** (optional, heterogeneous) - **T**:
72
82
  The bias tensor for input gate. Concatenation of [Wbi, Rbi] and
73
83
  [WBbi, RBbi] (if bidirectional). The tensor has shape
74
84
  [num_directions, 2*hidden_size]. Optional: If not specified -
75
85
  assumed to be 0.
76
86
  * **sequence_lens** (optional, heterogeneous) - **T1**:
77
87
  Optional tensor specifying lengths of the sequences in a batch. If
78
88
  not specified - assumed all sequences in the batch to have length
79
89
  seq_length. It has shape [batch_size].
80
90
  * **initial_h** (optional, heterogeneous) - **T**:
81
91
  Optional initial value of the hidden. If not specified - assumed to
82
92
  be 0. It has shape [num_directions, batch_size, hidden_size].
83
93
  **Outputs**
84
94
  Between 0 and 2 outputs.
85
95
  * **Y** (optional, heterogeneous) - **T**:
86
96
  A tensor that concats all the intermediate output values of the
87
97
  hidden. It has shape [seq_length, num_directions, batch_size,
88
98
  hidden_size].
89
99
  * **Y_h** (optional, heterogeneous) - **T**:
90
100
  The last output value of the hidden. It has shape [num_directions,
91
101
  batch_size, hidden_size].
92
102
  **Type Constraints**
93
103
  * **T** in (
94
104
  tensor(double),
95
105
  tensor(float),
96
106
  tensor(float16)
97
107
  ):
98
108
  Constrain input and output types to float tensors.
99
109
  * **T1** in (
100
110
  tensor(int32)
101
111
  ):
102
112
  Constrain seq_lens to integer tensor.