Fast sigmoid algorithm

后端 未结 11 1897
庸人自扰
庸人自扰 2020-12-12 15:55

The sigmoid function is defined as

I found that using the C built-in function exp() to calculate the value of f(x) is slow. Is th

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 16:22

    You can also use this:

        y=x / (2 * (x<0.0?-x:x) + 2) + 0.5;
        y'=y(1-y);
    

    acts like a sigmoid now because y(1-y)=y' is more let say round than 1/(2 (1 + abs(x))^2) acts more like to fast sigmoid;

提交回复
热议问题