SignActivation<T>
Models & Types · AiDotNet.ActivationFunctions
Implements the Sign activation function, which returns -1 for negative inputs, 1 for positive inputs, and 0 for zero.
Inheritance: ActivationFunctionBase<T> → SignActivation<T>
Implements: IFusedActivation
For Beginners
The Sign function is like a simple categorizer that looks at a number and tells you if it’s negative (-1), zero (0), or positive (1). It’s one of the simplest activation functions and is useful when you want your neural network to make clear-cut decisions rather than produce probabilities or continuous values. However, because it has sharp “jumps” in its output and its derivative is zero almost everywhere, it’s rarely used in modern neural networks that rely on gradient-based learning.
How It Works
The Sign function is a simple non-linear activation function that categorizes inputs into three distinct outputs: -1 (negative), 0 (zero), or 1 (positive). Unlike smooth activation functions, Sign has sharp transitions.
Example
using AiDotNet.ActivationFunctions;
var activation = new SignActivation<double>();
double y = activation.Activate(0.5);
Console.WriteLine($"SignActivation: f(0.5) = {y:F4}");
Constructors
| Constructor | Summary |
|---|---|
SignActivation() |
Methods
| Method | Summary |
|---|---|
Matrix<T> Derivative(Vector<T> input) |
Calculates the derivative of the Sign function for a tensor input. |
T Activate(T input) |
Applies the Sign activation function to each element in a tensor. |
T Derivative(T input) |
Calculates the derivative of the Sign function for a tensor input. |
Tensor<T> Activate(Tensor<T> input) |
Applies the Sign activation function to each element in a tensor. |
Tensor<T> Derivative(Tensor<T> input) |
Calculates the derivative of the Sign function for a tensor input. |
Vector<T> Activate(Vector<T> input) |
Applies the Sign activation function to each element in a tensor. |