Search in sources :

Example 1 with Feedforward

use of org.gitia.froog.Feedforward in project froog by mroodschild.

the class Feedforward2Test method testLayer.

@Test
public void testLayer() {
    Feedforward net = new Feedforward();
    net.addLayer(new Layer(4, 2, "tansig"));
    net.addLayer(new Layer(2, 2, "purelim"));
    assertEquals("Dimensiones Entrada", 8, net.getLayers().get(0).getW().getNumElements());
    assertEquals("Dimensiones Entrada", 4, net.getLayers().get(1).getW().getNumElements());
}
Also used : Feedforward(org.gitia.froog.Feedforward) Layer(org.gitia.froog.layer.Layer) Test(org.junit.Test)

Example 2 with Feedforward

use of org.gitia.froog.Feedforward in project froog by mroodschild.

the class Feedforward2Test method testSalida2.

@Test
public void testSalida2() {
    SimpleMatrix w1 = new SimpleMatrix(2, 2, true, 0.1, 0.2, 0.3, 0.4);
    SimpleMatrix b1 = new SimpleMatrix(2, 1, true, 0.5, 0.1);
    SimpleMatrix w2 = new SimpleMatrix(3, 2, true, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6);
    SimpleMatrix b2 = new SimpleMatrix(3, 1, true, 0.5, 0.1, 0.2);
    SimpleMatrix w3 = new SimpleMatrix(2, 3, true, 0.5, 0.6, 0.9, 0.7, 0.8, 1.0);
    SimpleMatrix b3 = new SimpleMatrix(2, 1, true, 0.2, 0.4);
    Feedforward net = new Feedforward();
    net.addLayer(new Layer(w1, b1, "tansig"));
    net.addLayer(new Layer(w2, b2, "tansig"));
    net.addLayer(new Layer(w3, b3, "purelim"));
    double[] entrada = { 0.2, 0.6 };
    double[] esperado = { 1.2686148090686, 1.7212904026294 };
    // List<Layer> layers = net.getLayers();
    // for (int i = 0; i < layers.size(); i++) {
    // Layer l = layers.get(i);
    // System.out.println("Layer: " + i + " tipo: " + l.toString());
    // l.getW().print();
    // }
    // System.out.println("Salida:");
    // net.output(entrada).print("%.4f");
    assertArrayEquals(esperado, net.output(entrada).getMatrix().getData(), 0.000000000001);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Feedforward(org.gitia.froog.Feedforward) Layer(org.gitia.froog.layer.Layer) Test(org.junit.Test)

Example 3 with Feedforward

use of org.gitia.froog.Feedforward in project froog by mroodschild.

the class Open method getNet.

public static Feedforward getNet(String file, String folder) {
    net = new Feedforward();
    archivo = new File(folder + "/" + file);
    if (archivo != null) {
        agregarCapas();
    }
    return net;
}
Also used : Feedforward(org.gitia.froog.Feedforward) File(java.io.File)

Example 4 with Feedforward

use of org.gitia.froog.Feedforward in project froog by mroodschild.

the class BackpropagationBachTest method testEntrenar.

/**
 * Test of entrenar method, of class BackpropagationBach.
 */
@Ignore
@Test
public void testEntrenar() {
    System.out.println("entrenar");
    Feedforward net = null;
    double[][] input = null;
    double[][] output = null;
    int iteraciones = 0;
    Backpropagation instance = new Backpropagation();
    instance.setEpoch(iteraciones);
    instance.entrenar(net, input, output);
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");
}
Also used : Backpropagation(org.gitia.froog.trainingalgorithm.Backpropagation) Feedforward(org.gitia.froog.Feedforward) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Feedforward

use of org.gitia.froog.Feedforward in project froog by mroodschild.

the class Feedforward2Test method testSalida.

@Test
public void testSalida() {
    SimpleMatrix w1 = new SimpleMatrix(2, 2, true, 0.1, 0.2, 0.3, 0.4);
    SimpleMatrix b1 = new SimpleMatrix(2, 1, true, 0.5, 0.1);
    SimpleMatrix w2 = new SimpleMatrix(2, 2, true, 0.5, 0.6, 0.7, 0.8);
    SimpleMatrix b2 = new SimpleMatrix(2, 1, true, 0.2, 0.4);
    Feedforward net = new Feedforward();
    net.addLayer(new Layer(w1, b1, "tansig"));
    net.addLayer(new Layer(w2, b2, "purelim"));
    double[] entrada = { 0.2, 0.6 };
    double[] esperado = { 0.7104, 1.0993 };
    assertArrayEquals(esperado, net.output(entrada).getMatrix().getData(), 0.0001);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Feedforward(org.gitia.froog.Feedforward) Layer(org.gitia.froog.layer.Layer) Test(org.junit.Test)

Aggregations

Feedforward (org.gitia.froog.Feedforward)6 Layer (org.gitia.froog.layer.Layer)4 Test (org.junit.Test)4 SimpleMatrix (org.ejml.simple.SimpleMatrix)3 Backpropagation (org.gitia.froog.trainingalgorithm.Backpropagation)2 File (java.io.File)1 IOException (java.io.IOException)1 Random (java.util.Random)1 STD (org.gitia.jdataanalysis.data.stats.STD)1 Ignore (org.junit.Ignore)1