Files
jube-fork/Accord.Neuro/AForge.Neuro/Activation Functions/ThresholdFunction.cs
richard-churchman cc0a2bee21 Extensive modifications to the serialisation of Neural Network models to support Newtonsoft Json.net rather than Binary Serializer.
Included open-source Accord.net library code natively to the solution given the deprecated state of that project.  Accord.net will be supported inside Jube for own needs (such as upgrading to .Net 7+).

Accord.net libraries modified to compile to .Net 6.

Modified Accord.net libraries to better support Newtonsoft Json.net serialisation.

Included annotations in the Accord.net libraries to house important dependency statistics. Serialised json can be used independently of Jube to recall a Neural Network.

Removal of Binary Serializer totally as a precursor to the projects support of .Net 7+.

Extensive bug fixing in crucial functions of Neural Network training and recall.  While this part of the system remains in Alpha, it is substantially more fit for purpose.
2023-12-24 10:22:22 +01:00

100 lines
2.8 KiB
C#

// AForge Neural Net Library
// AForge.NET framework
// http://www.aforgenet.com/framework/
//
// Copyright © AForge.NET, 2007-2012
// [email protected]
//
namespace Accord.Neuro
{
using System;
using Accord.Compat;
/// <summary>
/// Threshold activation function.
/// </summary>
///
/// <remarks><para>The class represents threshold activation function with
/// the next expression:
/// <code lang="none">
/// f(x) = 1, if x >= 0, otherwise 0
/// </code>
/// </para>
///
/// <para>Output range of the function: <b>[0, 1]</b>.</para>
///
/// <para>Functions graph:</para>
/// <img src="..\images\neuro\threshold.bmp" width="242" height="172" />
/// </remarks>
///
[Serializable]
public class ThresholdFunction : IActivationFunction, ICloneable
{
/// <summary>
/// Initializes a new instance of the <see cref="ThresholdFunction"/> class.
/// </summary>
public ThresholdFunction( ) { }
/// <summary>
/// Calculates function value.
/// </summary>
///
/// <param name="x">Function input value.</param>
///
/// <returns>Function output value, <i>f(x)</i>.</returns>
///
/// <remarks>The method calculates function value at point <paramref name="x"/>.</remarks>
///
public double Function( double x )
{
return ( x >= 0 ) ? 1 : 0;
}
/// <summary>
/// Calculates function derivative (not supported).
/// </summary>
///
/// <param name="x">Input value.</param>
///
/// <returns>Always returns 0.</returns>
///
/// <remarks><para><note>The method is not supported, because it is not possible to
/// calculate derivative of the function.</note></para></remarks>
///
public double Derivative( double x )
{
return 0;
}
/// <summary>
/// Calculates function derivative (not supported).
/// </summary>
///
/// <param name="y">Input value.</param>
///
/// <returns>Always returns 0.</returns>
///
/// <remarks><para><note>The method is not supported, because it is not possible to
/// calculate derivative of the function.</note></para></remarks>
///
public double Derivative2( double y )
{
return 0;
}
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
///
/// <returns>
/// A new object that is a copy of this instance.
/// </returns>
///
public object Clone( )
{
return new ThresholdFunction( );
}
}
}