快速sigmoid算法 [英] Fast sigmoid algorithm

查看:32
本文介绍了快速sigmoid算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sigmoid 函数定义为

The sigmoid function is defined as

我发现使用C内置函数exp()计算f(x)的值很慢.有没有更快的算法来计算 f(x) 的值?

I found that using the C built-in function exp() to calculate the value of f(x) is slow. Is there any faster algorithm to calculate the value of f(x)?

推荐答案

您不必在神经网络算法中使用实际的、精确的 sigmoid 函数,而是可以将其替换为具有相似属性但速度更快的近似版本计算.

you don't have to use the actual, exact sigmoid function in a neural network algorithm but can replace it with an approximated version that has similar properties but is faster the compute.

例如,你可以使用fast sigmoid"函数

For example, you can use the "fast sigmoid" function

  f(x) = x / (1 + abs(x))

如果 f(x) 的参数不接近零,则对 exp(x) 使用级数展开的第一项不会有太大帮助,并且如果参数很大".

Using first terms of the series expansion for exp(x) won't help too much if the arguments to f(x) are not near zero, and you have the same problem with a series expansion of the sigmoid function if the arguments are "large".

另一种方法是使用表查找.也就是说,您预先计算给定数量数据点的 sigmoid 函数值,然后根据需要在它们之间进行快速(线性)插值.

An alternative is to use table lookup. That is, you precalculate the values of the sigmoid function for a given number of data points, and then do fast (linear) interpolation between them if you want.

这篇关于快速sigmoid算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆