@Test(expected = Test.None.class) public void testUSPS() throws Exception { System.out.println("USPS SGD"); MathEx.setSeed(19650218); Standardizer scaler = Standardizer.fit(USPS.x); double[][] x = scaler.transform(USPS.x); double[][] testx = scaler.transform(USPS.testx); int p = x[0].length; int k = MathEx.max(USPS.y) + 1; MLP model = new MLP(p, Layer.rectifier(768), Layer.rectifier(192), Layer.rectifier(30), Layer.mle(k, OutputFunction.SIGMOID) ); model.setLearningRate(TimeFunction.linear(0.01, 20000, 0.001)); int error = 0; for (int epoch = 1; epoch <= 5; epoch++) { System.out.format("----- epoch %d -----%n", epoch); int[] permutation = MathEx.permutate(x.length); for (int i : permutation) { model.update(x[i], USPS.y[i]); } int[] prediction = Validation.test(model, testx); error = Error.of(USPS.testy, prediction); System.out.println("Test Error = " + error); } assertEquals(110, error); java.nio.file.Path temp = smile.data.Serialize.write(model); smile.data.Serialize.read(temp); }
@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);  }