Esempio n. 1
0
        public override double Compute(Indexer inputs, Indexer weights)
        {
            var prevIndex = -1;
            var nextIndex = -1;

            for (int i = 0; i < Table.Count; i++)
            {
                if (Table[i].Item1 < inputs[0])
                {
                    prevIndex = i;
                }
                else
                {
                    nextIndex = i;
                    break;
                }
            }
            if (prevIndex == -1)
            {
                prevIndex = nextIndex;
                nextIndex++;
            }
            if (nextIndex == -1)
            {
                nextIndex = prevIndex;
                prevIndex--;
            }

            var prev = Table[prevIndex];
            var next = Table[nextIndex];

            var k = (next.Item2 - prev.Item2) / (next.Item1 - prev.Item1);
            var b = prev.Item2 - k * prev.Item1;

            return(k * inputs[0] + b);
        }
Esempio n. 2
0
 public abstract void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative);
Esempio n. 3
0
 public abstract double Compute(Indexer inputs, Indexer weights);
Esempio n. 4
0
 public override void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative)
 {
     for (int i = 0; i < InputsCount; i++)
     {
         inputsDerivative[i] += error;
     }
 }
Esempio n. 5
0
 public override double Compute(Indexer inputs, Indexer weights)
 {
     return(inputs.Sum());
 }
Esempio n. 6
0
 public override void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative)
 {
     if (!IsFixed)
     {
         weightsDerivative[0] += error * LearningQ;
     }
 }
Esempio n. 7
0
 public override double Compute(Indexer inputs, Indexer weights)
 {
     return(weights[0]);
 }
Esempio n. 8
0
 public override void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative)
 {
     throw new NotImplementedException();
 }
Esempio n. 9
0
 public override double Compute(Indexer inputs, Indexer weights)
 {
     return(ShiftAfterMultuplication + Multiplier * (ShiftBeforeMultiplication + inputs[0]));
 }
Esempio n. 10
0
        public override void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative)
        {
            var sum = weights[inputsCount];

            for (int i = 0; i < inputsCount; i++)
            {
                sum += inputs[i] * weights[i];
            }

            var d = Function.Derivative(sum);

            if (double.IsNaN(d))
            {
                throw new Exception();
            }
            weightsDerivative[inputsCount] += error * d;
            for (int i = 0; i < inputsCount; i++)
            {
                weightsDerivative[i] += error * d * inputs[i];
                inputsDerivative[i]  += error * d * weights[i];
            }
        }
Esempio n. 11
0
 public override void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative)
 {
 }
Esempio n. 12
0
 public override void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative)
 {
     if (!DisableLearing)
     {
         inputsDerivative[0] += error;
     }
 }
Esempio n. 13
0
 public override double Compute(Indexer inputs, Indexer weights)
 {
     return(LastComputedValue = inputs[0]);
 }
Esempio n. 14
0
 public override double Compute(Indexer inputs, Indexer weights)
 {
     return(inputs.Aggregate((a, b) => a * b));
 }
Esempio n. 15
0
 public override void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative)
 {
     inputsDerivative[0] += error / Multiplier;
 }
Esempio n. 16
0
 public override void Derivative(double error, Indexer inputs, Indexer weights, Indexer inputsDerivative, Indexer weightsDerivative)
 {
     for (int i = 0; i < inputsCount; i++)
     {
         double product = 1;
         for (int j = 0; j < InputsCount; j++)
         {
             if (j == i)
             {
                 continue;
             }
             else
             {
                 product *= inputs[j];
             }
         }
         inputsDerivative[i] += error * product;
     }
 }
Esempio n. 17
0
 public override double Compute(Indexer inputs, Indexer weights)
 {
     throw new NotImplementedException();
 }