Пример #1
0
 private void CloneNeuralLayer(NeuralLayer neuralLayer)
 {
     _activationFunction = neuralLayer._activationFunction;
     _random             = neuralLayer._random;
     _weights            = new double[neuralLayer._weights.Length][];
     _neurons            = new Neuron[neuralLayer._neurons.Length];
     _biases             = new double[neuralLayer._biases.Length];
     for (int i = 0; i < _weights.Length; i++)
     {
         _biases[i]  = neuralLayer._biases[i];
         _weights[i] = new double[neuralLayer._weights[0].Length];
         for (int j = 0; j < _weights[i].Length; j++)
         {
             _weights[i][j] = neuralLayer._weights[i][j];
         }
     }
 }
Пример #2
0
    public NeuralLayer(int ammountOfNeurons, Random random, NeuralNetwork.ActivationFunction activationFunction)
    {
        if (ammountOfNeurons <= 0)
        {
            throw new ArgumentException("Amount of neurons has to be greater than zero.");
        }

        if (random == null)
        {
            throw new ArgumentNullException("Random has not been provided");
        }

        if (activationFunction == null)
        {
            throw new ArgumentNullException("Activation function has not been provided");
        }


        _activationFunction = activationFunction;
        _random             = random;
        _neurons            = new Neuron[ammountOfNeurons];
        InitializeWeights();
        InitializeBiases();
    }