@Override public void run() { for (int i = 0; i < numDocTopicIters; i++) { // synchronous read-only call: readModel.trainDocTopicModel(document, docTopics, docTopicModel); } if (writeModel != null) { // parallel call which is read-only on the docTopicModel, and write-only on the writeModel // this method does not return until all rows of the docTopicModel have been submitted // to write work queues writeModel.update(docTopicModel); } }
@Override public void run() { for (int i = 0; i < numDocTopicIters; i++) { // synchronous read-only call: readModel.trainDocTopicModel(document, docTopics, docTopicModel); } if (writeModel != null) { // parallel call which is read-only on the docTopicModel, and write-only on the writeModel // this method does not return until all rows of the docTopicModel have been submitted // to write work queues writeModel.update(docTopicModel); } }
@Override public void run() { for (int i = 0; i < numDocTopicIters; i++) { // synchronous read-only call: readModel.trainDocTopicModel(document, docTopics, docTopicModel); } if (writeModel != null) { // parallel call which is read-only on the docTopicModel, and write-only on the writeModel // this method does not return until all rows of the docTopicModel have been submitted // to write work queues writeModel.update(docTopicModel); } }
public void batchTrain(Map<Vector, Vector> batch, boolean update, int numDocTopicsIters) { while (true) { try { List<TrainerRunnable> runnables = Lists.newArrayList(); for (Map.Entry<Vector, Vector> entry : batch.entrySet()) { runnables.add(new TrainerRunnable(readModel, null, entry.getKey(), entry.getValue(), new SparseRowMatrix(numTopics, numTerms, true), numDocTopicsIters)); } threadPool.invokeAll(runnables); if (update) { for (TrainerRunnable runnable : runnables) { writeModel.update(runnable.docTopicModel); } } break; } catch (InterruptedException e) { log.warn("Interrupted during batch training, retrying!", e); } } }
public void batchTrain(Map<Vector, Vector> batch, boolean update, int numDocTopicsIters) { while (true) { try { List<TrainerRunnable> runnables = Lists.newArrayList(); for (Map.Entry<Vector, Vector> entry : batch.entrySet()) { runnables.add(new TrainerRunnable(readModel, null, entry.getKey(), entry.getValue(), new SparseRowMatrix(numTopics, numTerms, true), numDocTopicsIters)); } threadPool.invokeAll(runnables); if (update) { for (TrainerRunnable runnable : runnables) { writeModel.update(runnable.docTopicModel); } } break; } catch (InterruptedException e) { log.warn("Interrupted during batch training, retrying!", e); } } }
public void batchTrain(Map<Vector, Vector> batch, boolean update, int numDocTopicsIters) { while (true) { try { List<TrainerRunnable> runnables = new ArrayList<>(); for (Map.Entry<Vector, Vector> entry : batch.entrySet()) { runnables.add(new TrainerRunnable(readModel, null, entry.getKey(), entry.getValue(), new SparseRowMatrix(numTopics, numTerms, true), numDocTopicsIters)); } threadPool.invokeAll(runnables); if (update) { for (TrainerRunnable runnable : runnables) { writeModel.update(runnable.docTopicModel); } } break; } catch (InterruptedException e) { log.warn("Interrupted during batch training, retrying!", e); } } }