Esempio n. 1
0
        public Layer(
            WeightsMatrix weights,
            NetworkVector biases,
            ActivationFunction activationfunction,
            DerivativeFunction derivativefunction
            )
            : base(weights.NumberOfOutputs, weights.NumberOfInputs)
        {
            if (activationfunction != null && derivativefunction == null)
            {
                throw new ArgumentException("derivativefunction cannot be null, if activatioin is not null");
            }

            if (weights == null || biases == null)
            {
                throw new ArgumentException("Attempt to make a layer with null weights or biases.");
            }

            _combiner = new WeightedCombiner(weights, biases);

            if (activationfunction == null)
            {
                _neuralFunction = null;
            }
            else
            {
                _neuralFunction = new NeuralFunction(_combiner.NumberOfOutputs, activationfunction, derivativefunction);
            }
        }
Esempio n. 2
0
 public Layer(
     double[,] weights,
     double[] biases,
     ActivationFunction activationfunction,
     DerivativeFunction derivativefunction)
     : this(weights, biases, activationfunction, derivativefunction, TrainingMode.ONLINE)
 {
 }
Esempio n. 3
0
        public Layer(double[,] weights, ActivationFunction activationfunction, DerivativeFunction derivativefunction)
            : this(weights)
        {
            if (activationfunction != null && derivativefunction == null)
            {
                throw new ArgumentException("derivativefunction cannot be null, if activatioin is not null");
            }

            _neuralFunction = new NeuralFunction(NumberOfOutputs, activationfunction, derivativefunction);
        }
Esempio n. 4
0
        public NeuralFunction(int numberOfUnits, ActivationFunction activationfunction, DerivativeFunction derivativefunction, double[] biases = null)
            : this(numberOfUnits)
        {
            if (activationfunction != null && derivativefunction == null)
            {
                throw new ArgumentException("derivativefunction cannot be null, if activation is not null");
            }

            _neuralFunction           = activationfunction;
            _neuralFunctionDerivative = derivativefunction;
        }
Esempio n. 5
0
        public Layer(
            WeightsMatrix weights,
            BiasesVector biases,
            ActivationFunction activationfunction,
            DerivativeFunction derivativefunction
            )
            : base(weights, biases)
        {
            if (weights == null || biases == null)
            {
                throw new ArgumentException("Attempt to make a layer with null weights or biases.");
            }


            if (activationfunction == null)
            {
                _neuralFunction = null;
            }
            else
            {
                _neuralFunction = new NeuralFunction(NumberOfOutputs, activationfunction, derivativefunction);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Calculates the per-second derivative of the time series in a range vector, using simple linear regression.
 /// </summary>
 /// <returns></returns>
 public InstantVector Derivative()
 {
     AddAction(DerivativeFunction.Create());
     return(InstantVector.WithString(this));
 }