Ejemplo n.º 1
0
 public void AddLayer(NeuralLayer newLayer)
 {
     if (_layers.Any())
     {
         var lastLayer = _layers.Last();
         newLayer.ConnectLayers(lastLayer);
     }
     _layers.Add(newLayer);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Add layer to the neural network.
        /// Layer will automatically be added as the output layer to the last layer in the neural network.
        /// </summary>
        public void AddLayer(NeuralLayer newLayer)
        {
            if (_layers.Any())
            {
                var lastLayer = _layers.Last();
                newLayer.ConnectLayers(lastLayer);
            }

            _layers.Add(newLayer);
            _neuronErrors.Add(_layers.Count - 1, new double[newLayer.Neurons.Count]);
        }
Ejemplo n.º 3
0
        public void ConnectLayers_ConnectingLayers_ConnectionsAdded()
        {
            var inputNeuron  = new Mock <INeuron>();
            var outputNeuron = new Mock <INeuron>();

            inputNeuron.Setup(x => x.AddOutputNeuron(It.IsAny <INeuron>())).Verifiable();
            outputNeuron.Setup(x => x.AddInputNeuron(It.IsAny <INeuron>())).Verifiable();

            var inputNeuralLayer  = new NeuralLayer();
            var outputNeuralLayer = new NeuralLayer();

            inputNeuralLayer.Neurons.Add(inputNeuron.Object);
            outputNeuralLayer.Neurons.Add(outputNeuron.Object);

            outputNeuralLayer.ConnectLayers(inputNeuralLayer);

            outputNeuron.Verify(x => x.AddInputNeuron(It.Is <INeuron>(n => n == inputNeuron.Object)));
        }