Math optimization in C#

后端 未结 25 2360
悲&欢浪女
悲&欢浪女 2020-12-07 10:25

I\'ve been profiling an application all day long and, having optimized a couple bits of code, I\'m left with this on my todo list. It\'s the activation function for a neural

25条回答
  •  鱼传尺愫
    2020-12-07 10:54

    You might also consider experimenting with alternative activation functions which are cheaper to evaluate. For example:

    f(x) = (3x - x**3)/2
    

    (which could be factored as

    f(x) = x*(3 - x*x)/2
    

    for one less multiplication). This function has odd symmetry, and its derivative is trivial. Using it for a neural network requires normalizing the sum-of-inputs by dividing by the total number of inputs (limiting the domain to [-1..1], which is also range).

提交回复
热议问题