Search in sources :

Example 11 with Layer

use of org.gitia.froog.layer.Layer in project froog by mroodschild.

the class LayerTest method testOutputZ.

/**
 * Test of outputZ method, of class Layer.
 */
@Test
public void testOutputZ() {
    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);
    Layer layer = new Layer(w1, b1, "tansig");
    SimpleMatrix entrada = new SimpleMatrix(2, 1, true, 0.2, 0.6);
    double[] esperado = { 0.64, 0.4 };
    assertArrayEquals(esperado, layer.outputZ(entrada).getMatrix().getData(), 0.0001);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Layer(org.gitia.froog.layer.Layer) Test(org.junit.Test)

Example 12 with Layer

use of org.gitia.froog.layer.Layer in project froog by mroodschild.

the class LayerTest method testOutputZ.

/**
 * Test of outputZ method, of class Layer.
 */
@Test
@Ignore
public void testOutputZ() {
    System.out.println("outputZ");
    SimpleMatrix a = null;
    Layer instance = new Layer();
    SimpleMatrix expResult = null;
    SimpleMatrix result = instance.outputZ(a);
    assertEquals(expResult, result);
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Layer(org.gitia.froog.layer.Layer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with Layer

use of org.gitia.froog.layer.Layer in project froog by mroodschild.

the class LayerTest method testOutput_doubleArr.

/**
 * Test of output method, of class Layer.
 */
@Test
public void testOutput_doubleArr() {
    System.out.println("output");
    SimpleMatrix w = new SimpleMatrix(2, 3, true, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6);
    SimpleMatrix b = new SimpleMatrix(2, 1, true, 0.1, 0.2);
    double[] input = { 0.2, 0.4, 0.6 };
    Layer instance = new Layer(w, b, TransferFunction.LOGSIG);
    double[] expResult = { 0.5938731029341, 0.6984652160025 };
    double[] result = instance.output(input).getMatrix().getData();
    assertArrayEquals(expResult, result, 0.0000000000001);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Layer(org.gitia.froog.layer.Layer) Test(org.junit.Test)

Example 14 with Layer

use of org.gitia.froog.layer.Layer in project froog by mroodschild.

the class LayerTest method testOutputN.

/**
 * Test of outputN method, of class Layer.
 */
@Test
@Ignore
public void testOutputN() {
    System.out.println("outputN");
    SimpleMatrix z = null;
    Layer instance = new Layer();
    SimpleMatrix expResult = null;
    SimpleMatrix result = instance.outputN(z);
    assertEquals(expResult, result);
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Layer(org.gitia.froog.layer.Layer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with Layer

use of org.gitia.froog.layer.Layer in project froog by mroodschild.

the class Save method process.

private static void process(Feedforward net) {
    for (int i = 0; i < net.getLayers().size(); i++) {
        Layer layer = net.getLayers().get(i);
        formatter.format("\n<layer>");
        formatter.format("\n\t<transferFunction>%s</transferFunction>", layer.getFunction().toString());
        formatter.format("\n\t<w>%s</w>", Arrays.toString(layer.getW().getMatrix().data).replace("[", "").replace("]", ""));
        formatter.format("\n\t<bias>%s</bias>", Arrays.toString(layer.getB().getMatrix().data).replace("[", "").replace("]", ""));
        formatter.format("\n</layer>");
    }
}
Also used : Layer(org.gitia.froog.layer.Layer)

Aggregations

Layer (org.gitia.froog.layer.Layer)18 SimpleMatrix (org.ejml.simple.SimpleMatrix)14 Test (org.junit.Test)11 Feedforward (org.gitia.froog.Feedforward)4 IOException (java.io.IOException)2 Ignore (org.junit.Ignore)2 Random (java.util.Random)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Backpropagation (org.gitia.froog.trainingalgorithm.Backpropagation)1 STD (org.gitia.jdataanalysis.data.stats.STD)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1 SAXException (org.xml.sax.SAXException)1