hanaml.LSTM is an R wrapper for PAL Long Short-Term Memory(LSTM).

hanaml.LSTM(
  data = NULL,
  key = NULL,
  endog = NULL,
  exog = NULL,
  learning.rate = NULL,
  gru = NULL,
  batch.size = NULL,
  time.dim = NULL,
  hidden.dim = NULL,
  num.layers = NULL,
  max.iter = NULL,
  interval = NULL,
  optimizer = NULL,
  stateful = NULL,
  bidirectional = NULL
)

Arguments

data

DataFrame
DataFrame containting the data.

key

character, optional
Name of the time stamp column that represents the order of values in the time-series.
The type of this column should be INTEGER.

endog

character, optional
The endogenous variable, i.e. time series.
Defaults to the first non-ID column.

exog

character or list of characters, optional
An optional array of exogenous variables.
Defaults all other columns in data exclusive of key and endog.

learning.rate

double, optional
Specifies the learning rate for gradient descent.
Defaults to 0.01

gru

logical, optional
Specifies whether or not the use gated recurrent units(GRUs) instead of regular LSTM in recurrent neural network structure.
If FALSE, only regular LSTM is used.
Defaults to FALSE.

batch.size

integer, optional
Number of pieces of data for training in one optimization iteration.
Defaults to 32.

time.dim

integer, optional
Specifying how many time steps in a sequence that will be trained by LSTM/GRU and then for time series prediction.
This value must be smaller than the length of input time series minus 1.
Defaults to 16.

hidden.dim

integer, optional
Number of hidden neurons in LSTM/GRU unit.
Defaults to 128.

num.layers

integer, optional
Number of layers in LSTM/GRU unit.
Defaults to 1.

max.iter

integer, optional
Maximum number of iterations, equivalent to maximum number of batches of data by which LSTM/GRU is trained.
Defaults to 1000.

interval

integer, optional
Output the average loss within every interval iterations.
Defaults to 100.

optimizer

c("SGD", "RMSprop", "Adam", "Adagrad"), optional
Specifying which optimizer is used to train the LSTM/GRU model.
Defaults to "Adam".

stateful

logical, optional
If the value is TRUE, it enables stateful LSTM/GRU. Defaults to TRUE.

bidirectional

logical, optional
If the value is TRUE, it uses bidirectional LSTM/GRU.
Otherwise, it uses LSTM/GRU.
Defaults to FALSE.

Value

Returns an "LSTM" object with the following attributes:

  • loss: DataFrame
    For storing the the average loss in every interval iterations.

  • model: DataFrame
    Fitted LSTM/GRU model.

Details

Long short-term memory (LSTM) is one of the most famous modules of Recurrent Neural Networks(RNN). It can not only process single data point, but also the entire sequences of data, such as speech and stock prices.

Examples

Input DataFrame df:


> df$Head(3)$Collect()
   TIMESTAMP  SERIES
1          0    20.7
2          1    17.9
3          2    18.8

Create an LSTM instance:


> lstm <- LSTM(data = df,
               key = "TIMESTAMP",
               gru=FALSE,
               bidirectional=FALSE,
               time.dim=16,
               max.iter=1000,
               learning.rate=0.01,
               batch.size=32,
               hidden.dim=128,
               num.layers=1,
               interval=1,
               stateful=FALSE,
               optimizer="Adam")

Peform predict on the fittd model:


> res <- predict(lstm, df.predict)

Expected output:


> res$Select(c("ID", "VALUE"))$Head(3)$Collect()
   ID      VALUE
1   0  11.673560
2   1  14.057195
3   2  15.119411

See also