Accelerating mathematical computation in Java

I have a neural network written in Java, which uses sigmoid transfer function to define as follows:

private static double sigmoid(double x)
{
    return 1 / (1 + Math.exp(-x));
}

This is called multiple training and calculation using network Is there any way to speed up this? It's not very slow, but it's used a lot, so a small optimization here will be a big overall benefit

Solution

For neural networks, you do not need the exact value of the sigmoid function Therefore, you can pre calculate 100 values and re-use the value closest to the input, or even better (as a comment), to interpolate from the neighbor value

You can do this, this article description (link stolen from answer of s-lott)

This is the sigmoid function:

As you can see, only - 10 ℃ x < 10 is very interesting Another commented that this function is symmetrical You only need to store half the value Editor: sorry, I show the wrong chart here I've corrected it

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>