Args: input_size (int): The number of expected features in the input x hidden_size (int): The number of features in the hidden state h num_layers (int): Number of recurrent layers. Default: 1 nonlinearity (string): The non-linearity to use.
(
self,
input_size,
hidden_size,
nonlinearity="tanh",
num_layers=1,
bias=True,
batch_first=False,
dropout=0,
bidirectional=False,
)
| 1232 | """ |
| 1233 | |
| 1234 | def __init__( |
| 1235 | self, |
| 1236 | input_size, |
| 1237 | hidden_size, |
| 1238 | nonlinearity="tanh", |
| 1239 | num_layers=1, |
| 1240 | bias=True, |
| 1241 | batch_first=False, |
| 1242 | dropout=0, |
| 1243 | bidirectional=False, |
| 1244 | ): |
| 1245 | """ |
| 1246 | Args: |
| 1247 | input_size (int): The number of expected features in the input x |
| 1248 | hidden_size (int): The number of features in the hidden state h |
| 1249 | num_layers (int): Number of recurrent layers. Default: 1 |
| 1250 | nonlinearity (string): The non-linearity to use. Default: 'tanh' |
| 1251 | bias (bool): If False, then the layer does not use bias weights. |
| 1252 | Default: True |
| 1253 | batch_first (bool): If True, then the input and output tensors |
| 1254 | are provided as (batch, seq, feature). Default: False |
| 1255 | dropout (float): If non-zero, introduces a Dropout layer on the |
| 1256 | outputs of each RNN layer except the last layer, with dropout |
| 1257 | probability equal to dropout. Default: 0 |
| 1258 | bidirectional (bool): If True, becomes a bidirectional RNN. |
| 1259 | Default: False |
| 1260 | """ |
| 1261 | super(LSTM, self).__init__() |
| 1262 | |
| 1263 | self.input_size = input_size |
| 1264 | self.hidden_size = hidden_size |
| 1265 | self.num_layers = num_layers |
| 1266 | self.nonlinearity = nonlinearity |
| 1267 | self.bias = bias |
| 1268 | self.batch_first = batch_first |
| 1269 | self.dropout = dropout |
| 1270 | self.bidirectional = bidirectional |
| 1271 | |
| 1272 | def initialize(self, xs, h0_c0): |
| 1273 | # 1. Wx_i input, Bx_i |