- Configure the neural network with default configurations:
NeuralNetConfiguration.Builder neuralNetConfigBuilder = new NeuralNetConfiguration.Builder();
neuralNetConfigBuilder.seed(123);
neuralNetConfigBuilder.weightInit(WeightInit.XAVIER);
neuralNetConfigBuilder.updater(new Nadam());
neuralNetConfigBuilder.gradientNormalization(GradientNormalization.ClipElementWiseAbsoluteValue);
neuralNetConfigBuilder.gradientNormalizationThreshold(0.5);
- Specify the input layer labels by calling addInputs():
ComputationGraphConfiguration.GraphBuilder compGraphBuilder = neuralNetConfigBuilder.graphBuilder();
compGraphBuilder.addInputs("trainFeatures");
- Add an LSTM layer using the addLayer() method:
compGraphBuilder.addLayer("L1", new LSTM.Builder().activation(Activation.TANH).nIn(1).nOut(10).build(), "trainFeatures");