@Test public void testACPolicy() throws Exception { ComputationGraph cg = new ComputationGraph(new NeuralNetConfiguration.Builder().seed(444).graphBuilder().addInputs("input") .addLayer("output", new OutputLayer.Builder().nOut(1).lossFunction(LossFunctions.LossFunction.XENT).activation(Activation.SIGMOID).build(), "input").setOutputs("output").build()); MultiLayerNetwork mln = new MultiLayerNetwork(new NeuralNetConfiguration.Builder().seed(555).list() .layer(0, new OutputLayer.Builder().nOut(1).lossFunction(LossFunctions.LossFunction.XENT).activation(Activation.SIGMOID).build()).build()); ACPolicy policy = new ACPolicy(new DummyAC(mln), true, Nd4j.getRandom()); INDArray input = Nd4j.create(new double[] {1.0, 0.0}, new long[]{1,2}); for (int i = 0; i < 100; i++) { assertEquals(0, (int)policy.nextAction(input)); } input = Nd4j.create(new double[] {0.0, 1.0}, new long[]{1,2}); for (int i = 0; i < 100; i++) { assertEquals(1, (int)policy.nextAction(input)); } input = Nd4j.create(new double[] {0.1, 0.2, 0.3, 0.4}, new long[]{1, 4}); int[] count = new int[4]; for (int i = 0; i < 100; i++) { count[policy.nextAction(input)]++; } assertTrue(count[0] < 20); assertTrue(count[1] < 30); assertTrue(count[2] < 40); assertTrue(count[3] < 50); }
public abstract A nextAction(Observation obs);
Policy implements INeuralNetPolicy<A> { public abstract A nextAction(Observation obs); }
Policy implements INeuralNetPolicy<A> { public abstract A nextAction(Observation obs);  }
Policy implements INeuralNetPolicy<A> { public abstract A nextAction(Observation obs);  abstract IOutputNeuralNet getNeuralNet(); abstract A nextAction(Observation obs); @Deprecated double play(MDP<O, A, AS> mdp); @Deprecated double play(MDP<O, A, AS> mdp, HistoryProcessor.Configuration conf); @Deprecated @Override double play(MDP<O, A, AS> mdp, IHistoryProcessor hp); void reset(); }
Policy implements INeuralNetPolicy<A> { public abstract A nextAction(Observation obs);  abstract IOutputNeuralNet getNeuralNet(); abstract A nextAction(Observation obs); @Deprecated double play(MDP<O, A, AS> mdp); @Deprecated double play(MDP<O, A, AS> mdp, HistoryProcessor.Configuration conf); @Deprecated @Override double play(MDP<O, A, AS> mdp, IHistoryProcessor hp); void reset();  }