@Test public void when_callingOnTrainingProgress_expect_callToDataManagerSaveAndWriteInfo() { TestTrainer learning = new TestTrainer(); MockDataManager dm = new MockDataManager(false); DataManagerTrainingListener sut = new DataManagerTrainingListener(dm); TrainingListener.ListenerResponse response = sut.onTrainingProgress(learning); assertEquals(TrainingListener.ListenerResponse.CONTINUE, response); assertEquals(1, dm.writeInfoCallCount); assertEquals(1, dm.saveCallCount); }
@Override public ListenerResponse onTrainingProgress(ILearning learning) { try { int stepCounter = learning.getStepCount(); if (stepCounter - lastSave >= Constants.MODEL_SAVE_FREQ) { dataManager.save(learning); lastSave = stepCounter; } dataManager.writeInfo(learning); } catch (Exception e) { log.error("Training failed.", e); return ListenerResponse.STOP; } return ListenerResponse.CONTINUE; }
DataManagerTrainingListener implements TrainingListener { @Override public ListenerResponse onTrainingProgress(ILearning learning) { try { int stepCounter = learning.getStepCount(); if (stepCounter - lastSave >= Constants.MODEL_SAVE_FREQ) { dataManager.save(learning); lastSave = stepCounter; } dataManager.writeInfo(learning); } catch (Exception e) { log.error("Training failed.", e); return ListenerResponse.STOP; } return ListenerResponse.CONTINUE; } }
DataManagerTrainingListener implements TrainingListener { @Override public ListenerResponse onTrainingProgress(ILearning learning) { try { int stepCounter = learning.getStepCount(); if (stepCounter - lastSave >= Constants.MODEL_SAVE_FREQ) { dataManager.save(learning); lastSave = stepCounter; } dataManager.writeInfo(learning); } catch (Exception e) { log.error("Training failed.", e); return ListenerResponse.STOP; } return ListenerResponse.CONTINUE; } DataManagerTrainingListener(IDataManager dataManager); }
DataManagerTrainingListener implements TrainingListener { @Override public ListenerResponse onTrainingProgress(ILearning learning) { try { int stepCounter = learning.getStepCount(); if (stepCounter - lastSave >= Constants.MODEL_SAVE_FREQ) { dataManager.save(learning); lastSave = stepCounter; } dataManager.writeInfo(learning); } catch (Exception e) { log.error("Training failed.", e); return ListenerResponse.STOP; } return ListenerResponse.CONTINUE; } DataManagerTrainingListener(IDataManager dataManager); @Override ListenerResponse onTrainingStart(); @Override void onTrainingEnd(); @Override ListenerResponse onNewEpoch(IEpochTrainer trainer); @Override ListenerResponse onEpochTrainingResult(IEpochTrainer trainer, IDataManager.StatEntry statEntry); @Override ListenerResponse onTrainingProgress(ILearning learning); }
DataManagerTrainingListener implements TrainingListener { @Override public ListenerResponse onTrainingProgress(ILearning learning) { try { int stepCounter = learning.getStepCount(); if (stepCounter - lastSave >= Constants.MODEL_SAVE_FREQ) { dataManager.save(learning); lastSave = stepCounter; } dataManager.writeInfo(learning); } catch (Exception e) { log.error("Training failed.", e); return ListenerResponse.STOP; } return ListenerResponse.CONTINUE; } DataManagerTrainingListener(IDataManager dataManager); @Override ListenerResponse onTrainingStart(); @Override void onTrainingEnd(); @Override ListenerResponse onNewEpoch(IEpochTrainer trainer); @Override ListenerResponse onEpochTrainingResult(IEpochTrainer trainer, IDataManager.StatEntry statEntry); @Override ListenerResponse onTrainingProgress(ILearning learning);  }