@Test public void testUpdateModel() { int nIn = 5; val conf = new NeuralNetConfiguration.Builder() .graphBuilder() .addInputs("in") .layer("out0", new OutputLayer.Builder().nIn(nIn).nOut(4).activation(Activation.SOFTMAX).build(), "in") .layer("out1", new OutputLayer.Builder().nIn(nIn).nOut(6).activation(Activation.SOFTMAX).build(), "in") .setOutputs("out0", "out1") .build(); val net = new ComputationGraph(conf); net.init(); val pi = new ParallelInference.Builder(net) .inferenceMode(InferenceMode.INPLACE) .workers(2) .build(); try { assertTrue(pi instanceof InplaceParallelInference); val models = pi.getCurrentModelsFromWorkers(); assertTrue(models.length > 0); for (val m : models) { assertNotNull(m); assertEquals(net.params(), m.params()); } val conf2 = new NeuralNetConfiguration.Builder() .graphBuilder() .addInputs("in") .layer("out0", new OutputLayer.Builder().nIn(nIn).nOut(4).activation(Activation.SOFTMAX).build(), "in") .layer("out1", new OutputLayer.Builder().nIn(nIn).nOut(6).activation(Activation.SOFTMAX).build(), "in") .layer("out2", new OutputLayer.Builder().nIn(nIn).nOut(8).activation(Activation.SOFTMAX).build(), "in") .setOutputs("out0", "out1", "out2") .build(); val net2 = new ComputationGraph(conf2); net2.init(); assertNotEquals(net.params(), net2.params()); pi.updateModel(net2); val models2 = pi.getCurrentModelsFromWorkers(); assertTrue(models2.length > 0); for (val m : models2) { assertNotNull(m); assertEquals(net2.params(), m.params()); } } finally { pi.shutdown(); } }
@Override public synchronized void updateModel(@NonNull Model model) { for (val h:holders) h.updateModel(model); }
InplaceParallelInference extends ParallelInference { @Override public synchronized void updateModel(@NonNull Model model) { for (val h:holders) h.updateModel(model); } }
InplaceParallelInference extends ParallelInference { @Override public synchronized void updateModel(@NonNull Model model) { for (val h:holders) h.updateModel(model); }  }
InplaceParallelInference extends ParallelInference { @Override public synchronized void updateModel(@NonNull Model model) { for (val h:holders) h.updateModel(model); }  @Override synchronized void updateModel(@NonNull Model model); @Override INDArray[] output(INDArray[] input, INDArray[] inputMasks); T output(@NonNull ModelAdapter<T> adapter, INDArray[] input, INDArray[] inputMasks, INDArray[] labelsMasks); }
InplaceParallelInference extends ParallelInference { @Override public synchronized void updateModel(@NonNull Model model) { for (val h:holders) h.updateModel(model); }  @Override synchronized void updateModel(@NonNull Model model); @Override INDArray[] output(INDArray[] input, INDArray[] inputMasks); T output(@NonNull ModelAdapter<T> adapter, INDArray[] input, INDArray[] inputMasks, INDArray[] labelsMasks);  }