Tanh
public static double Mytanh(double value) {
double ex = Math.pow(Math.E, value);// e^x
double ey = Math.pow(Math.E, -value);//e^(-x)
double sinhx = ex-ey;
double coshx = ex+ey;
double result = sinhx/coshx;
return result;
}
Tanh求导
public static double tanhDerivative(double value) {
double result = 1-Mytanh(value)*Mytanh(value);
return result;
}