Long Short-Term Memory Networks (LSTM) example
Code: "recurn_lstm3.py". Programming language: Python DMelt Version 1.9. Last modified: 12/07/2017. License: Pro
https://datamelt.org/code/cache/recurn_lstm3_1145.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


# see http://cs.stanford.edu/people/karpathy/recurrentjs/
# This demo shows usage of the recurrentjs library that allows you to train deep Recurrent Neural Networks (RNN) and Long Short-Term Memory Networks (LSTM)


from java.util import Random
from recunn.datastructs import DataSet
from recunn.model import Model
from recunn.trainer import Trainer
from recunn.util import NeuralNetworkHelper
from recunn.datasets import EmbeddedReberGrammar


rng = Random()
data = EmbeddedReberGrammar(rng)
hiddenDimension = 12
hiddenLayers = 1
learningRate = 0.001
initParamsStdDev = 0.08

nn = NeuralNetworkHelper.makeLstm( 
     data.inputDimension,
     hiddenDimension, hiddenLayers, 
     data.outputDimension, data.getModelOutputUnitToUse(), 
     initParamsStdDev, rng)
        
reportEveryNthEpoch = 10
trainingEpochs = 1000
Trainer.train(trainingEpochs, learningRate, nn, data, reportEveryNthEpoch, rng)



Ads help maintain this website.