public static void freeze(State<Wrapper, CrossFoldLearner> s) { // radically decrease learning rate double[] params = s.getParams(); params[1] -= 10; // and cause evolution to hold (almost) s.setOmni(s.getOmni() / 20); double[] step = s.getStep(); for (int i = 0; i < step.length; i++) { step[i] /= 20; } }
public static void freeze(State<Wrapper, CrossFoldLearner> s) { // radically decrease learning rate double[] params = s.getParams(); params[1] -= 10; // and cause evolution to hold (almost) s.setOmni(s.getOmni() / 20); double[] step = s.getStep(); for (int i = 0; i < step.length; i++) { step[i] /= 20; } }
public static void freeze(State<Wrapper, CrossFoldLearner> s) { // radically decrease learning rate double[] params = s.getParams(); params[1] -= 10; // and cause evolution to hold (almost) s.setOmni(s.getOmni() / 20); double[] step = s.getStep(); for (int i = 0; i < step.length; i++) { step[i] /= 20; } }
@Test public void testConverges() throws Exception { State<Foo, Double> s0 = new State<Foo, Double>(new double[5], 1); s0.setPayload(new Foo()); EvolutionaryProcess<Foo, Double> ep = new EvolutionaryProcess<Foo, Double>(10, 100, s0); State<Foo, Double> best = null; for (int i = 0; i < 20; i++) { best = ep.parallelDo(new EvolutionaryProcess.Function<Payload<Double>>() { @Override public double apply(Payload<Double> payload, double[] params) { int i = 1; double sum = 0; for (double x : params) { sum += i * (x - i) * (x - i); i++; } return -sum; } }); ep.mutatePopulation(3); System.out.printf("%10.3f %.3f\n", best.getValue(), best.getOmni()); } ep.close(); assertNotNull(best); assertEquals(0.0, best.getValue(), 0.02); }