Step 6 - LSTM network construction

Now, let's set up an LSTM model with the preceding parameters and structure:

val model = LSTMNetworkConstructor.setupModel(nSteps, nInput, nHidden, nClasses, batchSize, ctx = ctx) 

In the preceding line, setupModel() is the method that does the trick. The getSymbol() method actually constructs the LSTM cell. We will see its signature, too, later on. It accepts sequence length, number of input, number of hidden layers, number of labels, batch size, number of LSTM layers, dropout MXNet context, and constructs an LSTM model of type using the case class LSTMModel:

case class LSTMModel(exec: Executor, symbol: Symbol, data: NDArray, label: NDArray, argsDict: Map[String, NDArray], gradDict: Map[String, NDArray]) ...

Get Scala Machine Learning Projects now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.