Source:
public void run(final int iteration) { final long epochStartTime = System.currentTimeMillis(); final int numEMBlocks = memoryStore.getNumBlocks(); WorkerMetrics workerMetrics; int miniBatchIdx = 0; int numDocumentsSampled = 0; final List<Document> totalDocumentsSampled = new LinkedList<>(); Map<Long, Document> nextTrainingData = trainingDataProvider.getNextTrainingData(); Collection<Document> documents = nextTrainingData.values(); int numInstancesToProcess = documents.size(); while (!nextTrainingData.isEmpty()) { resetTracers(); final long miniBatchStartTime = System.currentTimeMillis(); sampler.sample(documents, computeTracer, pushTracer, pullTracer); numDocumentsSampled += numDocumentsSampled; totalDocumentsSampled.addAll(documents); LOG.log(Level.INFO, "{0} documents have been sampled until mini-batch {1}", new Object[]{numDocumentsSampled, miniBatchIdx}); nextTrainingData = trainingDataProvider.getNextTrainingData(); final double miniBatchElapsedTime = (System.currentTimeMillis() - miniBatchStartTime) / 1000.0D; workerMetrics = buildMiniBatchMetric(iteration, miniBatchIdx, numInstancesToProcess, miniBatchElapsedTime); LOG.log(Level.INFO, "WorkerMetrics {0}", workerMetrics); sendMetrics(workerMetrics); documents = nextTrainingData.values(); numInstancesToProcess = documents.size(); miniBatchIdx++; } LOG.log(Level.INFO, "Pull model to compute log likelihood"); final List<int[]> wordTopicCounts = parameterWorker.pull(vocabList); final int[] wordTopicCountsSummary = wordTopicCounts.remove(numVocabs); LOG.log(Level.INFO, "Start computing log likelihood"); final double docLLH = statCalculator.computeDocLLH(totalDocumentsSampled); final double wordLLH = statCalculator.computeWordLLH(wordTopicCounts, wordTopicCountsSummary); final double epochElapsedTime = (System.currentTimeMillis() - epochStartTime) / 1000.0D; workerMetrics = buildEpochMetric(iteration, miniBatchIdx, numEMBlocks, numDocumentsSampled, docLLH, wordLLH, epochElapsedTime); LOG.log(Level.INFO, "WorkerMetrics {0}", workerMetrics); sendMetrics(workerMetrics); }

Target:
public void run(final int iteration) { final long epochStartTime = System.currentTimeMillis(); final int numEMBlocks = memoryStore.getNumBlocks(); int miniBatchIdx = 0; int numDocumentsSampled = 0; final List<Document> totalDocumentsSampled = new LinkedList<>(); Map<Long, Document> nextTrainingData = trainingDataProvider.getNextTrainingData(); Collection<Document> documents = nextTrainingData.values(); int numInstancesToProcess = documents.size(); while (!nextTrainingData.isEmpty()) { resetTracers(); final long miniBatchStartTime = System.currentTimeMillis(); sampler.sample(documents, computeTracer, pushTracer, pullTracer); numDocumentsSampled += numInstancesToProcess; totalDocumentsSampled.addAll(documents); LOG.log(Level.INFO, "{0} documents have been sampled until mini-batch {1}", new Object[]{numDocumentsSampled, miniBatchIdx}); nextTrainingData = trainingDataProvider.getNextTrainingData(); final double miniBatchElapsedTime = (System.currentTimeMillis() - miniBatchStartTime) / 1000.0D; final WorkerMetrics miniBatchMetric = buildMiniBatchMetric(iteration, miniBatchIdx, numInstancesToProcess, miniBatchElapsedTime); LOG.log(Level.INFO, "WorkerMetrics {0}", miniBatchMetric); sendMetrics(miniBatchMetric); documents = nextTrainingData.values(); numInstancesToProcess = documents.size(); miniBatchIdx++; } LOG.log(Level.INFO, "Pull model to compute log likelihood"); final List<int[]> wordTopicCounts = parameterWorker.pull(vocabList); final int[] wordTopicCountsSummary = wordTopicCounts.remove(numVocabs); LOG.log(Level.INFO, "Start computing log likelihood"); final double docLLH = statCalculator.computeDocLLH(totalDocumentsSampled); final double wordLLH = statCalculator.computeWordLLH(wordTopicCounts, wordTopicCountsSummary); final double epochElapsedTime = (System.currentTimeMillis() - epochStartTime) / 1000.0D; final WorkerMetrics epochMetric = buildEpochMetric(iteration, miniBatchIdx, numEMBlocks, numDocumentsSampled, docLLH, wordLLH, epochElapsedTime); LOG.log(Level.INFO, "WorkerMetrics {0}", epochMetric); sendMetrics(epochMetric); }