O'Reilly logo

Java Deep Learning Projects by Md. Rezaul Karim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Network training, and saving the trained model

Now that our network as well as the training and test sets are ready, we can start training the network. For this, again we use the DL4J-provided fit() method. We loop through epochs times, for each time looping until we have the data. We fit the network with a miniBatchSize amount of data at each time step, as shown here:

// StockPricePrediction.javaSystem.out.println("Training LSTM network...");for(int i = 0; i < epochs; i++) {            while(iterator.hasNext()) net.fit(iterator.next()); // fit model using mini-batch data            iterator.reset(); // reset iterator            net.rnnClearPreviousState(); // clear previous state        }>> Creating dataSet iterator... Loading test dataset... Building LSTM networks... Training ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required