@Test public void when_callingRecurrentStepOutput_expect_recurrentStepCalledWithObservationData() { setup(false); Observation observationMock = mock(Observation.class); double[] recurrentStepOutput1 = new double[] { 1.0, 2.0, 3.0}; double[] recurrentStepOutput2 = new double[] { 10.0, 20.0, 30.0}; when(handler1.recurrentStepOutput(observationMock)).thenReturn(new INDArray[] { Nd4j.create(recurrentStepOutput1) }); when(handler2.recurrentStepOutput(observationMock)).thenReturn(new INDArray[] { Nd4j.create(recurrentStepOutput2) }); INDArray[] results = sut.recurrentStepOutput(observationMock); verify(handler1, times(1)).recurrentStepOutput(observationMock); verify(handler2, times(1)).recurrentStepOutput(observationMock); assertEquals(2, results.length); assertArrayEquals(results[0].toDoubleVector(), recurrentStepOutput1, 0.00001); assertArrayEquals(results[1].toDoubleVector(), recurrentStepOutput2, 0.00001); }
@Override public INDArray[] recurrentStepOutput(Observation observation) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.recurrentStepOutput(observation)); } return outputs.toArray(new INDArray[0]); }
CompoundNetworkHandler implements INetworkHandler { @Override public INDArray[] recurrentStepOutput(Observation observation) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.recurrentStepOutput(observation)); } return outputs.toArray(new INDArray[0]); } }
CompoundNetworkHandler implements INetworkHandler { @Override public INDArray[] recurrentStepOutput(Observation observation) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.recurrentStepOutput(observation)); } return outputs.toArray(new INDArray[0]); } CompoundNetworkHandler(INetworkHandler... networkHandlers); }
CompoundNetworkHandler implements INetworkHandler { @Override public INDArray[] recurrentStepOutput(Observation observation) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.recurrentStepOutput(observation)); } return outputs.toArray(new INDArray[0]); } CompoundNetworkHandler(INetworkHandler... networkHandlers); @Override void notifyGradientCalculation(); @Override void notifyIterationDone(); @Override void performFit(FeaturesLabels featuresLabels); @Override void performGradientsComputation(FeaturesLabels featuresLabels); @Override void fillGradientsResponse(Gradients gradients); @Override void applyGradient(Gradients gradients, long batchSize); @Override INDArray[] recurrentStepOutput(Observation observation); @Override INDArray[] batchOutput(INDArray batch); @Override void resetState(); @Override INetworkHandler clone(); @Override void copyFrom(INetworkHandler from); }
CompoundNetworkHandler implements INetworkHandler { @Override public INDArray[] recurrentStepOutput(Observation observation) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.recurrentStepOutput(observation)); } return outputs.toArray(new INDArray[0]); } CompoundNetworkHandler(INetworkHandler... networkHandlers); @Override void notifyGradientCalculation(); @Override void notifyIterationDone(); @Override void performFit(FeaturesLabels featuresLabels); @Override void performGradientsComputation(FeaturesLabels featuresLabels); @Override void fillGradientsResponse(Gradients gradients); @Override void applyGradient(Gradients gradients, long batchSize); @Override INDArray[] recurrentStepOutput(Observation observation); @Override INDArray[] batchOutput(INDArray batch); @Override void resetState(); @Override INetworkHandler clone(); @Override void copyFrom(INetworkHandler from);  }