Learn R Programming

sits (version 0.10.0)

sits_LSTM_FCN: Train a model using the a combination of LSTM and CNN

Description

Use a combination of an LSTM (Long Short Term Memory) and a cascade of 1D-CNN newtorks to classify data. Users can define the number of convolutional layers, the size of the convolutional kernels, and the activation functions.

#' This function is based on the paper by Karim et al. referenced below and the code made available on github (https://github.com/titu1994/LSTM-FCN) If you use this method, please cite the original paper.

Usage

sits_LSTM_FCN(
  samples = NULL,
  lstm_units = 8,
  lstm_dropout = 0.8,
  cnn_layers = c(128, 256, 128),
  cnn_kernels = c(8, 5, 3),
  activation = "relu",
  optimizer = keras::optimizer_adam(lr = 0.001),
  epochs = 150,
  batch_size = 128,
  validation_split = 0.2,
  verbose = 1
)

Arguments

samples

Time series with the training samples.

lstm_units

Number of cells in the each LSTM layer

lstm_dropout

Dropout rate of the LSTM module

cnn_layers

Number of filters for each 1D CNN layer.

cnn_kernels

Size of the 1D convolutional kernels.

activation

Activation function for 1D convolution. Valid values: 'relu', 'elu', 'selu', 'sigmoid'.

optimizer

Function with a pointer to the optimizer function (default is optimization_adam()). Options: optimizer_adadelta(), optimizer_adagrad(), optimizer_adam(), optimizer_adamax(), optimizer_nadam(), optimizer_rmsprop(), optimizer_sgd().

epochs

Number of iterations to train the model.

batch_size

Number of samples per gradient update.

validation_split

Number between 0 and 1. Fraction of training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the x and y data provided, before shuffling.

verbose

Verbosity mode (0 = silent, 1 = progress bar, 2 = one line per epoch).

Value

A fitted model to be passed to sits_classify

References

Fazle Karim, Somshubra Majumdar, Houshang Darabi, Sun Chen, "LSTM fully convolutional networks for time series classification", IEEE Access, 6(1662-1669), 2018.

Examples

Run this code
# NOT RUN {
# Retrieve the set of samples for the Mato Grosso (provided by EMBRAPA)

# Build a machine learning model based on deep learning
lstm_cnn_model <- sits_train(samples_mt_4bands, sits_LSTM_FCN())

# plot the model
plot(lstm_cnn_model)

# get a point and classify the point with the ml_model
point <- sits_select(point_mt_6bands,
    bands = c("NDVI", "EVI", "NIR", "MIR")
)
class <- sits_classify(point, lstm_cnn_model)
plot(class, bands = c("NDVI", "EVI"))
# }

Run the code above in your browser using DataLab