手记

JAVA 神经网络 tanh(x),双曲正切函数

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;
    }
2人推荐
随时随地看视频
慕课网APP