|
3 | 3 | using System.Text; |
4 | 4 | using Tensorflow.Keras.ArgsDefinition; |
5 | 5 | using Tensorflow.Keras.Layers; |
| 6 | +using Tensorflow.Operations.Activation; |
6 | 7 | using static Tensorflow.Binding; |
7 | 8 |
|
8 | 9 | namespace Tensorflow.Keras.Engine |
@@ -100,5 +101,46 @@ protected Layer Flatten() |
100 | 101 | _layers.Add(layer); |
101 | 102 | return layer; |
102 | 103 | } |
| 104 | + |
| 105 | + protected Layer LSTM(int units, |
| 106 | + Activation activation = null, |
| 107 | + Activation recurrent_activation = null, |
| 108 | + bool use_bias = true, |
| 109 | + IInitializer kernel_initializer = null, |
| 110 | + IInitializer recurrent_initializer = null, |
| 111 | + IInitializer bias_initializer = null, |
| 112 | + bool unit_forget_bias = true, |
| 113 | + float dropout = 0f, |
| 114 | + float recurrent_dropout = 0f, |
| 115 | + int implementation = 2, |
| 116 | + bool return_sequences = false, |
| 117 | + bool return_state = false, |
| 118 | + bool go_backwards = false, |
| 119 | + bool stateful = false, |
| 120 | + bool time_major = false, |
| 121 | + bool unroll = false) |
| 122 | + { |
| 123 | + var layer = new LSTM(new LSTMArgs |
| 124 | + { |
| 125 | + Units = units, |
| 126 | + Activation = activation ?? tf.keras.activations.Tanh, |
| 127 | + RecurrentActivation = recurrent_activation ?? tf.keras.activations.Sigmoid, |
| 128 | + KernelInitializer = kernel_initializer ?? tf.glorot_uniform_initializer, |
| 129 | + RecurrentInitializer = recurrent_initializer ?? tf.orthogonal_initializer, |
| 130 | + BiasInitializer = bias_initializer ?? tf.zeros_initializer, |
| 131 | + Dropout = dropout, |
| 132 | + RecurrentDropout = recurrent_dropout, |
| 133 | + Implementation = implementation, |
| 134 | + ReturnSequences = return_sequences, |
| 135 | + ReturnState = return_state, |
| 136 | + GoBackwards = go_backwards, |
| 137 | + Stateful = stateful, |
| 138 | + TimeMajor = time_major, |
| 139 | + Unroll = unroll |
| 140 | + }); |
| 141 | + |
| 142 | + _layers.Add(layer); |
| 143 | + return layer; |
| 144 | + } |
103 | 145 | } |
104 | 146 | } |
0 commit comments