June 2018
Intermediate to advanced
436 pages
10h 33m
English
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 ...