Пример #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);
            }
        }
Пример #2
0
        public Layer(double[,] weights, double[] biases, TrainingMode mode)
            : base(mode)
        {
            int numberOfOutputs = weights.GetLength(0);
            int numberOfInputs  = weights.GetLength(1);

            _combiner       = new WeightedCombiner(weights, biases);
            _neuralFunction = null;
        }
Пример #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);
        }
Пример #4
0
        protected Layer(Layer layer)
            : base(layer.Mode)
        {
            if (layer == null)
            {
                throw new ArgumentException("Attempt to create a LayerBank with a null layer.");
            }

            _combiner       = layer._combiner;
            _neuralFunction = layer._neuralFunction;
        }