public void CreationStep_CorrectlyOutsideTerm(double input) { var zero = TermCore.Create(0); var one = TermCore.Create(1); zero.AccumulatedError = 1; one.AccumulatedError = 1; var layers = new TermLayer <LinearMembershipFunction>(new[] { zero, one }); layers.CreationStep(input, 0, 0); Assert.AreEqual(5, layers.Cores.Length); Assert.IsTrue(layers.Cores.Any(z => Math.Abs(z.X - input) < 1e-5)); }
public void CreationStep_CorrectlyCreatedMidleTerm(double input) { var zero = TermCore.Create(0); var one = TermCore.Create(1); zero.AccumulatedError = 1; one.AccumulatedError = 1; var layers = new TermLayer <LinearMembershipFunction>(new[] { zero, one }); layers.CreationStep(input, 0, 0); Assert.AreEqual(5, layers.Cores.Length); Assert.AreEqual(input, layers.Cores[2].X); }
public void BackpropError_AccumulatedErrorComputedCorrectly() { var zero = TermCore.Create(0); var one = TermCore.Create(1); var layers = new TermLayer <LinearMembershipFunction>(new[] { zero, one }, learningRate: 1e-1, smoothingAverageRate: 1e-1); for (var i = 0; i < 100; i++) { layers.BackpropError(0, 5); layers.BackpropError(1, -3); } Assert.AreEqual(5, zero.AccumulatedError, 1e-2); Assert.AreEqual(-3, one.AccumulatedError, 1e-2); }
public void BackpropError_CoresLearnedCorrectly(double initialZero, double initialOne) { var zero = TermCore.Create(initialZero); var one = TermCore.Create(initialOne); var layers = new TermLayer <LinearMembershipFunction>(new[] { zero, one }, learningRate: 1e-1); for (var i = 0; i < 100; i++) { layers.BackpropError(0, -zero.X); layers.BackpropError(1, 1.0 - one.X); } Assert.AreEqual(0, zero.X, 1e-2); Assert.AreEqual(1, one.X, 1e-2); }