using Esiur.Analysis.Neural; using System; using System.Collections.Generic; using System.Text; namespace Esiur.Analysis.Algebra { public static class Functions { private static MathFunction SigmoidDerivative = new MathFunction(new RealFunction(x => x * (1 - x)), null, null); public static MathFunction Sigmoid = new MathFunction(new RealFunction(x => { double k = Math.Exp(x); return k / (1.0 + k); }), SigmoidDerivative, null); private static MathFunction TanhDerivative = new MathFunction( new RealFunction(x => 1 - (x * x)), null, null); public static MathFunction Tanh = new MathFunction( new RealFunction(x => Math.Tanh(x)), TanhDerivative, null); private static MathFunction ReLUDerivative = new MathFunction( new RealFunction(x => (0 >= x) ? 0 : 1), null, null); public static MathFunction ReLU = new MathFunction( new RealFunction(x => (0 >= x) ? 0 : x), ReLUDerivative, null); private static MathFunction LeakyReLUDerivative = new MathFunction( new RealFunction(x => (0 >= x) ? 0.01 : 1), null, null); public static MathFunction LeakyReLU = new MathFunction( new RealFunction(x => (0 >= x) ? 0.01 * x : x), LeakyReLUDerivative, null); } }