Search in sources :

Example 1 with TransferFunction

use of org.gitia.froog.transferfunction.TransferFunction in project froog by mroodschild.

the class PurelimTest method testDerivative.

/**
 * Test of derivative method, of class Purelim.
 */
@Test
public void testDerivative() {
    TransferFunction purelim = FunctionFactory.getFunction("purelim");
    SimpleMatrix a = new SimpleMatrix(1, 5, true, -3, -1, 0, 1, 3);
    double[] salida = purelim.derivative(a).getMatrix().getData();
    double[] esperado = { 1, 1, 1, 1, 1 };
    assertArrayEquals(esperado, salida, 0.000000001);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) TransferFunction(org.gitia.froog.transferfunction.TransferFunction) Test(org.junit.Test)

Example 2 with TransferFunction

use of org.gitia.froog.transferfunction.TransferFunction in project froog by mroodschild.

the class PurelimTest method testOutput.

/**
 * Test of output method, of class Purelim.
 */
@Test
public void testOutput() {
    TransferFunction purelim = FunctionFactory.getFunction("purelim");
    SimpleMatrix a = new SimpleMatrix(1, 5, true, -3, -1, 0, 1, 3);
    double[] salida = purelim.output(a).getMatrix().getData();
    double[] esperado = { -3, -1, 0, 1, 3 };
    assertArrayEquals(esperado, salida, 0.000000001);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) TransferFunction(org.gitia.froog.transferfunction.TransferFunction) Test(org.junit.Test)

Example 3 with TransferFunction

use of org.gitia.froog.transferfunction.TransferFunction in project froog by mroodschild.

the class SoftmaxTest method testOutput.

/**
 * Test of output method, of class Softmax.
 */
@Test
public void testOutput() {
    TransferFunction softmax = FunctionFactory.getFunction("softmax");
    SimpleMatrix z = new SimpleMatrix(5, 1, true, -3, -1, 0, 1, 3);
    double[] salida = softmax.output(z).getMatrix().getData();
    double[] esperado = { 0.002055492, 0.015188145, 0.04128566, 0.112226059, 0.829244644 };
    // softmax.output(z).print();
    assertArrayEquals(esperado, salida, 0.000000001);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) TransferFunction(org.gitia.froog.transferfunction.TransferFunction) Test(org.junit.Test)

Example 4 with TransferFunction

use of org.gitia.froog.transferfunction.TransferFunction in project froog by mroodschild.

the class SoftmaxTest method testToString.

/**
 * Test of toString method, of class Softmax.
 */
@Test
public void testToString() {
    TransferFunction tansig = FunctionFactory.getFunction("softmax");
    String expResult = "softmax";
    String result = tansig.toString();
    assertEquals(expResult, result);
}
Also used : TransferFunction(org.gitia.froog.transferfunction.TransferFunction) Test(org.junit.Test)

Example 5 with TransferFunction

use of org.gitia.froog.transferfunction.TransferFunction in project froog by mroodschild.

the class TansigTest method testOutput.

/**
 * Test of output method, of class Tansig. -1 + 2 / (1 + e^(-2 . x))
 */
@Test
public void testOutput() {
    TransferFunction tansig = FunctionFactory.getFunction("tansig");
    SimpleMatrix a = new SimpleMatrix(1, 5, true, -0.25, -0.1, 0, 0.2, 0.5);
    double[] salida = tansig.output(a).getMatrix().getData();
    double[] esperado = { -0.2449186624037, -0.0996679946250, 0.0000000000000, 0.1973753202249, 0.4621171572600 };
    assertArrayEquals(esperado, salida, 0.000000001);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) TransferFunction(org.gitia.froog.transferfunction.TransferFunction) Test(org.junit.Test)

Aggregations

TransferFunction (org.gitia.froog.transferfunction.TransferFunction)13 Test (org.junit.Test)11 SimpleMatrix (org.ejml.simple.SimpleMatrix)10