Source:
private static void setListeners(ComputationGraph computationGraph, DataNormalization dataNormalization, ParentPathLabelGenerator labelMaker, int epochs) { try { UIServer uiServer = UIServer.getInstance(); ImageRecordReader trainingRecordReader = new ImageRecordReader(height, width, channels, labelMaker); trainingRecordReader.initialize(trainingData, getImageTransform(currentEpoch)); DataSetIterator trainingDataSetIterator = new RecordReaderDataSetIterator(trainingRecordReader, batchSize, 1, outputNum); dataNormalization.fit(trainingDataSetIterator); trainingDataSetIterator.setPreProcessor(dataNormalization); EvaluativeListener evaluativeTrainingListener = new EvaluativeListener(trainingDataSetIterator, epochs, InvocationType.EPOCH_END, new Evaluation(outputNum)); ImageRecordReader validationRecordReader = new ImageRecordReader(height, width, channels, labelMaker); validationRecordReader.initialize(validationData, null); DataSetIterator validationDataSetIterator = new RecordReaderDataSetIterator(validationRecordReader, batchSize, 1, outputNum); dataNormalization.fit(validationDataSetIterator); validationDataSetIterator.setPreProcessor(dataNormalization); EvaluativeListener evaluativeValidationListener = new EvaluativeListener(validationDataSetIterator, epochs, InvocationType.EPOCH_END, new Evaluation(outputNum)); StatsStorage statsStorage = new InMemoryStatsStorage(); StatsListener statsListener = new StatsListener(statsStorage); ScoreIterationListener scoreIterationListener = new ScoreIterationListener(1); File model = new File(MODEL_PATH); if (!model.exists()) { model.mkdir(); } CheckpointListener checkpointListener = new CheckpointListener.Builder(new File(MODEL_PATH)) .keepAll() .saveEveryNEpochs(epochs) .build(); uiServer.attach(statsStorage); computationGraph.setListeners(evaluativeValidationListener, statsListener, scoreIterationListener, checkpointListener); } catch (IOException e) { e.printStackTrace(); } }

Target:
private static void setListeners(ComputationGraph computationGraph, DataNormalization dataNormalization, ParentPathLabelGenerator labelMaker, int epochs) { try { UIServer uiServer = UIServer.getInstance(); ImageRecordReader trainingRecordReader = new ImageRecordReader(height, width, channels, labelMaker); trainingRecordReader.initialize(trainingData, getImageTransform()); DataSetIterator trainingDataSetIterator = new RecordReaderDataSetIterator(trainingRecordReader, batchSize, 1, outputNum); dataNormalization.fit(trainingDataSetIterator); trainingDataSetIterator.setPreProcessor(dataNormalization); EvaluativeListener evaluativeTrainingListener = new EvaluativeListener(trainingDataSetIterator, epochs, InvocationType.EPOCH_END, new Evaluation(outputNum)); ImageRecordReader validationRecordReader = new ImageRecordReader(height, width, channels, labelMaker); validationRecordReader.initialize(validationData, null); DataSetIterator validationDataSetIterator = new RecordReaderDataSetIterator(validationRecordReader, batchSize, 1, outputNum); dataNormalization.fit(validationDataSetIterator); validationDataSetIterator.setPreProcessor(dataNormalization); EvaluativeListener evaluativeValidationListener = new EvaluativeListener(validationDataSetIterator, epochs, InvocationType.EPOCH_END, new Evaluation(outputNum)); StatsStorage statsStorage = new InMemoryStatsStorage(); StatsListener statsListener = new StatsListener(statsStorage); ScoreIterationListener scoreIterationListener = new ScoreIterationListener(1); File model = new File(MODEL_PATH); boolean newRun = false; if (!model.exists()) { newRun = model.mkdir(); } CheckpointListener checkpointListener = new CheckpointListener.Builder(model) .keepAll() .deleteExisting(!newRun) .saveEveryNEpochs(epochs) .build(); uiServer.attach(statsStorage); computationGraph.setListeners(evaluativeValidationListener, statsListener, scoreIterationListener, checkpointListener); } catch (IOException e) { e.printStackTrace(); } }