This repository was archived by the owner on May 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAFAnalogElliot.cs
More file actions
53 lines (46 loc) · 1.33 KB
/
AFAnalogElliot.cs
File metadata and controls
53 lines (46 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using RCNet.Extensions;
using RCNet.MathTools;
using System;
namespace RCNet.Neural.Activation
{
/// <summary>
/// Implements the Elliot (aka Softsign) activation function.
/// </summary>
[Serializable]
public class AFAnalogElliot : AFAnalogBase
{
//Attribute properties
/// <summary>
/// The curve slope.
/// </summary>
public double Slope { get; }
//Constructor
/// <summary>
/// Creates an initialized instance.
/// </summary>
/// <param name="slope">The slope of the curve.</param>
public AFAnalogElliot(double slope)
: base(Interval.IntN1P1)
{
Slope = slope.Bound();
if (Slope <= 0)
{
throw new ArgumentOutOfRangeException("slope", "Slope must be GT 0");
}
return;
}
//Methods
/// <inheritdoc/>
public override double Compute(double x)
{
x = x.Bound();
return ((x * Slope) / (1d + Math.Abs(x * Slope))).Bound();
}
/// <inheritdoc/>
public override double ComputeDerivative(double c, double x)
{
c = c.Bound();
return (Slope * 1d) / ((1d + Math.Abs(c * Slope)).Power(2));
}
}//AFAnalogElliot
}//Namespace