@Test public void when_handleGradientsIsCalledWithTarget_expect_gradientsAppliedOnGlobalCurrentAndTargetUpdated() { NeuralNetUpdaterConfiguration configuration = NeuralNetUpdaterConfiguration.builder() .targetUpdateFrequency(2) .build(); AsyncSharedNetworksUpdateHandler sut = new AsyncSharedNetworksUpdateHandler(globalCurrentMock, targetMock, configuration); Gradients gradients = new Gradients(10); sut.handleGradients(gradients); sut.handleGradients(gradients); verify(globalCurrentMock, times(2)).applyGradients(gradients); verify(targetMock, times(1)).copyFrom(globalCurrentMock); }
public void handleGradients(Gradients gradients) { globalCurrent.applyGradients(gradients); ++updateCount; if(target != null) { syncTargetNetwork(); } }
AsyncSharedNetworksUpdateHandler { public void handleGradients(Gradients gradients) { globalCurrent.applyGradients(gradients); ++updateCount; if(target != null) { syncTargetNetwork(); } } }
AsyncSharedNetworksUpdateHandler { public void handleGradients(Gradients gradients) { globalCurrent.applyGradients(gradients); ++updateCount; if(target != null) { syncTargetNetwork(); } } AsyncSharedNetworksUpdateHandler(@NonNull ITrainableNeuralNet globalCurrent,
                                            @NonNull NeuralNetUpdaterConfiguration configuration);  AsyncSharedNetworksUpdateHandler(@NonNull ITrainableNeuralNet globalCurrent,
                                            @NonNull ITrainableNeuralNet target,
                                            @NonNull NeuralNetUpdaterConfiguration configuration); }
AsyncSharedNetworksUpdateHandler { public void handleGradients(Gradients gradients) { globalCurrent.applyGradients(gradients); ++updateCount; if(target != null) { syncTargetNetwork(); } } AsyncSharedNetworksUpdateHandler(@NonNull ITrainableNeuralNet globalCurrent,
                                            @NonNull NeuralNetUpdaterConfiguration configuration);  AsyncSharedNetworksUpdateHandler(@NonNull ITrainableNeuralNet globalCurrent,
                                            @NonNull ITrainableNeuralNet target,
                                            @NonNull NeuralNetUpdaterConfiguration configuration); void handleGradients(Gradients gradients); }
AsyncSharedNetworksUpdateHandler { public void handleGradients(Gradients gradients) { globalCurrent.applyGradients(gradients); ++updateCount; if(target != null) { syncTargetNetwork(); } } AsyncSharedNetworksUpdateHandler(@NonNull ITrainableNeuralNet globalCurrent,
                                            @NonNull NeuralNetUpdaterConfiguration configuration);  AsyncSharedNetworksUpdateHandler(@NonNull ITrainableNeuralNet globalCurrent,
                                            @NonNull ITrainableNeuralNet target,
                                            @NonNull NeuralNetUpdaterConfiguration configuration); void handleGradients(Gradients gradients);  }