30 lines
773 B
Java
30 lines
773 B
Java
package net.woodyfolsom.msproj.ann2;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
import net.woodyfolsom.msproj.ann2.math.ActivationFunction;
|
|
import net.woodyfolsom.msproj.ann2.math.Sigmoid;
|
|
import net.woodyfolsom.msproj.ann2.math.Tanh;
|
|
|
|
import org.junit.Test;
|
|
|
|
public class SigmoidTest {
|
|
static double EPS = 0.001;
|
|
|
|
@Test
|
|
public void testCalculate() {
|
|
|
|
ActivationFunction sigmoid = Sigmoid.function;
|
|
assertEquals(0.5,sigmoid.calculate(0.0),EPS);
|
|
assertTrue(sigmoid.calculate(100.0) > 1.0 - EPS);
|
|
assertTrue(sigmoid.calculate(-9000.0) < EPS);
|
|
}
|
|
|
|
@Test
|
|
public void testDerivative() {
|
|
ActivationFunction sigmoid = new Tanh();
|
|
assertEquals(1.0,sigmoid.derivative(0.0), EPS);
|
|
}
|
|
}
|