matrices[0] = new DenseDoubleMatrix(5, 3, 0.5);
matrices[1] = new DenseDoubleMatrix(1, 6, 0.5);
ann.setWeightMatrices(matrices);
double[] arr = new double[] { 0, 1 };
DoubleVector training = new DenseDoubleVector(arr);
DoubleVector result = ann.getOutput(training);
assertEquals(1, result.getDimension());
// assertEquals(3, result.get(0), 0.000001);
// second network
SmallLayeredNeuralNetwork ann2 = new SmallLayeredNeuralNetwork();
ann2.addLayer(2, false, FunctionFactory.createDoubleFunction("Sigmoid"));
ann2.addLayer(3, false, FunctionFactory.createDoubleFunction("Sigmoid"));
ann2.addLayer(1, true, FunctionFactory.createDoubleFunction("Sigmoid"));
ann2.setCostFunction(FunctionFactory
.createDoubleDoubleFunction("SquaredError"));
ann2.setLearningRate(0.3);
// intentionally initialize all weights to 0.5
DoubleMatrix[] matrices2 = new DenseDoubleMatrix[2];
matrices2[0] = new DenseDoubleMatrix(3, 3, 0.5);
matrices2[1] = new DenseDoubleMatrix(1, 4, 0.5);
ann2.setWeightMatrices(matrices2);
double[] test = { 0, 0 };
double[] result2 = { 0.807476 };
DoubleVector vec = ann2.getOutput(new DenseDoubleVector(test));
assertArrayEquals(result2, vec.toArray(), 0.000001);
SmallLayeredNeuralNetwork ann3 = new SmallLayeredNeuralNetwork();
ann3.addLayer(2, false, FunctionFactory.createDoubleFunction("Sigmoid"));
ann3.addLayer(3, false, FunctionFactory.createDoubleFunction("Sigmoid"));
ann3.addLayer(1, true, FunctionFactory.createDoubleFunction("Sigmoid"));
ann3.setCostFunction(FunctionFactory
.createDoubleDoubleFunction("SquaredError"));
ann3.setLearningRate(0.3);
// intentionally initialize all weights to 0.5
DoubleMatrix[] initMatrices = new DenseDoubleMatrix[2];
initMatrices[0] = new DenseDoubleMatrix(3, 3, 0.5);
initMatrices[1] = new DenseDoubleMatrix(1, 4, 0.5);
ann3.setWeightMatrices(initMatrices);
double[] instance = { 0, 1 };
DoubleVector output = ann3.getOutput(new DenseDoubleVector(instance));
assertEquals(0.8315410, output.get(0), 0.000001);
}