Hands-On Neural Network Programming with C#
上QQ阅读APP看书,第一时间看更新

Sigmoid function

The Sigmoid function is an activation function and, as we previously, perhaps one of the most widely used today. Here's what a Sigmoid function looks like (you do remember our section on activation functions, right?) Its sole purpose (very abstractly) is to bring in the values from the outside edges closer to 0 and 1 without having to worry about values larger than this. This will prevent those values along the edge from running away on us:

What does a Sigmoid function look like in C# code, you might ask? Just like the following:

public static class Sigmoid
{
public static double Output(double x)
{
return x < -45.0 ?0.0 : x > 45.0 ? 1.0 : 1.0 / (1.0 + Math.Exp(-x));
}

public static double Derivative(double x)
{
return x * (1 - x);
}
}

Our Sigmoid class will produce the output and the Derivative.