@Test public void testPenDigits() { System.out.println("Pen Digits"); WinsorScaler scaler = WinsorScaler.fit(PenDigits.x, 0.01, 0.99); double[][] x = scaler.transform(PenDigits.x); int p = x[0].length; int k = MathEx.max(PenDigits.y) + 1; MathEx.setSeed(19650218); int[] prediction = CrossValidation.classification(10, x, PenDigits.y, (xi, yi) -> { MLP model = new MLP(p, Layer.sigmoid(50), Layer.mle(k, OutputFunction.SIGMOID) ); model.setLearningRate(TimeFunction.linear(0.2, 10000, 0.1)); model.setMomentum(TimeFunction.constant(0.5)); for (int epoch = 1; epoch <= 8; epoch++) { int[] permutation = MathEx.permutate(xi.length); for (int i : permutation) { model.update(xi[i], yi[i]); } } return model; }); int error = Error.of(PenDigits.y, prediction); System.out.println("Error = " + error); assertEquals(100, error); }
@Override public void update(double[] x, int y) { propagate(x); setTarget(labels.indexOf(y)); backpropagate(x, true); t++; }
MLP extends MultilayerPerceptron implements OnlineClassifier<double[]>, SoftClassifier<double[]>, Serializable { @Override public void update(double[] x, int y) { propagate(x); setTarget(labels.indexOf(y)); backpropagate(x, true); t++; } }
MLP extends MultilayerPerceptron implements OnlineClassifier<double[]>, SoftClassifier<double[]>, Serializable { @Override public void update(double[] x, int y) { propagate(x); setTarget(labels.indexOf(y)); backpropagate(x, true); t++; } MLP(int p, LayerBuilder... builders);  MLP(IntSet labels, int p, LayerBuilder... builders); }
MLP extends MultilayerPerceptron implements OnlineClassifier<double[]>, SoftClassifier<double[]>, Serializable { @Override public void update(double[] x, int y) { propagate(x); setTarget(labels.indexOf(y)); backpropagate(x, true); t++; } MLP(int p, LayerBuilder... builders);  MLP(IntSet labels, int p, LayerBuilder... builders); @Override int predict(double[] x, double[] posteriori); @Override int predict(double[] x); @Override void update(double[] x, int y); @Override void update(double[][] x, int[] y); }
MLP extends MultilayerPerceptron implements OnlineClassifier<double[]>, SoftClassifier<double[]>, Serializable { @Override public void update(double[] x, int y) { propagate(x); setTarget(labels.indexOf(y)); backpropagate(x, true); t++; } MLP(int p, LayerBuilder... builders);  MLP(IntSet labels, int p, LayerBuilder... builders); @Override int predict(double[] x, double[] posteriori); @Override int predict(double[] x); @Override void update(double[] x, int y); @Override void update(double[][] x, int[] y);  }