Description Usage Arguments Value References See Also Examples
Currently supports "simple unit", "gated recurrent unit" (GRU) and "Long-Short Term Memory" (LSTM) using Keras framework (with TensorFlow backend)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
X |
list of "train", "val", and "test" with 3D (keras) arrays |
Y |
list of "train", "val", and "test" with 2D (keras) arrays |
model_type |
One of "simple", "gru" and "lstm" |
tsteps |
number of time steps for keras input shape |
n_epochs |
default 200 |
n_units |
32 (currently fixed) |
loss |
default "mse" |
metrics |
default NULL |
dropout_in_test |
apply dropout during training only (default) or during testing also? Required for dropout-based prediction intervals (bayesian RNN) |
optimizer |
from keras, e.g. optimizer_rmsprop |
dropout |
dropout rate |
recurrent_dropout |
Dropout rate applied to reccurent layer. Default 0 |
history |
in addition to model, return model history? Beware that output
changes from |
live_plot |
plot loss and validation metric during training? False by default |
Keras model by default (history = FALSE
) else list with Keras model
and history
Chollet, Francois and others (2015). Keras. https://keras.io
Hochreiter, S., & Schmidhuber, J. (1997). Long Short-Term Memory. Neural Computation, 9 (8), 1735-1780. https://doi.org/10.1162/neco.1997.9.8.1735
Chung, J., Gulcehre, C., Cho, K., & Bengio, Y. (2014). Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling. https://arxiv.org/pdf/1412.3555
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | data <- tsRNN::DT_apple
data[, value_lag1 := data.table::shift(value, type = "lag", n = 1)]
data <- data[!is.na(get(paste0("value_lag1")))]
nn_arrays <- ts_nn_preparation(data, tsteps = 1L, length_val = 6L, length_test = 6L)
keras_rnn(nn_arrays$x, nn_arrays$y, model_type = "simple", tsteps = 1, n_epochs = 20)
# return model and history
result <- keras_rnn(
nn_arrays$x, nn_arrays$y, model_type = "simple", tsteps = 1, n_epochs = 20, history = TRUE
)
result$model
result$history
## Not run:
# Plot result
plot(result$history)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.