24 lines
451 B
Java
24 lines
451 B
Java
package net.woodyfolsom.msproj.ann.math;
|
|
|
|
import javax.xml.bind.annotation.XmlRootElement;
|
|
|
|
public class Tanh extends ActivationFunction{
|
|
public static final Tanh function = new Tanh();
|
|
|
|
public Tanh() {
|
|
super("Tanh");
|
|
}
|
|
|
|
@Override
|
|
public double calculate(double arg) {
|
|
return Math.tanh(arg);
|
|
}
|
|
|
|
@Override
|
|
public double derivative(double arg) {
|
|
double tanh = Math.tanh(arg);
|
|
return 1 - Math.pow(tanh, 2);
|
|
}
|
|
|
|
}
|