@Test public void when_callingBatchOutput_expect_outputCalledWithBatch() { setup(false); INDArray batch = Nd4j.rand(1, 2); when(handler1.batchOutput(batch)).thenReturn(new INDArray[] { batch.mul(2.0) }); when(handler2.batchOutput(batch)).thenReturn(new INDArray[] { batch.div(2.0) }); INDArray[] results = sut.batchOutput(batch); verify(handler1, times(1)).batchOutput(batch); verify(handler2, times(1)).batchOutput(batch); assertEquals(2, results.length); assertArrayEquals(results[0].toDoubleVector(), batch.mul(2.0).toDoubleVector(), 0.00001); assertArrayEquals(results[1].toDoubleVector(), batch.div(2.0).toDoubleVector(), 0.00001); }
@Override public INDArray[] batchOutput(INDArray batch) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.batchOutput(batch)); } return outputs.toArray(new INDArray[0]); }
CompoundNetworkHandler implements INetworkHandler { @Override public INDArray[] batchOutput(INDArray batch) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.batchOutput(batch)); } return outputs.toArray(new INDArray[0]); } }
CompoundNetworkHandler implements INetworkHandler { @Override public INDArray[] batchOutput(INDArray batch) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.batchOutput(batch)); } return outputs.toArray(new INDArray[0]); } CompoundNetworkHandler(INetworkHandler... networkHandlers); }
CompoundNetworkHandler implements INetworkHandler { @Override public INDArray[] batchOutput(INDArray batch) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.batchOutput(batch)); } 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[] batchOutput(INDArray batch) { List<INDArray> outputs = new ArrayList<INDArray>(); for(INetworkHandler handler : networkHandlers) { Collections.addAll(outputs, handler.batchOutput(batch)); } 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);  }