public static ThreeLayer copy( Map map, int hidden, int examples, double learningRate, double initVar) { ThreeLayer copy = random(map.dimension(), hidden, initVar, Activations.sigmoid()); MVN source = new MVN(map.dimension()); for (int i : series(examples)) { Point x = source.generate(), y = map.map(x); copy.train(x, y, learningRate); } return copy; }
@Override public ThreeLayer build(List<Double> parameters) { ThreeLayer fnn = new ThreeLayer(); fnn.n = n; fnn.h = h; fnn.activation = activation; fnn.stateIn = new ArrayRealVector(n + 1); fnn.stateIn.setEntry(n, 1.0); // * bias node fnn.stateHidden = new ArrayRealVector(h + 1); fnn.stateHidden.setEntry(h, 1.0); // * bias node fnn.stateOut = new ArrayRealVector(n); fnn.weights0 = new Array2DRowRealMatrix(h, n + 1); fnn.weights1 = new Array2DRowRealMatrix(n, h + 1); fnn.weights0Delta = new Array2DRowRealMatrix(h, n + 1); fnn.weights1Delta = new Array2DRowRealMatrix(n, h + 1); fnn.gHidden = new ArrayRealVector(h); fnn.eHiddenL = new ArrayRealVector(h + 1); fnn.eHidden = new ArrayRealVector(h); int c = 0; for (int i : series(h)) // to for (int j : series(n + 1)) // from fnn.weights0.setEntry(i, j, parameters.get(c++)); for (int i : series(n)) // to for (int j : series(h + 1)) // from fnn.weights1.setEntry(i, j, parameters.get(c++)); return fnn; }