Ejemplo n.º 1
0
        public Network(ILayer inputLayer, ILayer[] hiddenLayers, ILayer outputLayer)
        {
            this.InputLayer   = inputLayer;
            this.HiddenLayers = hiddenLayers;
            this.OutputLayer  = outputLayer;

            this.Neurons = InputLayer.Neurons.Concat(OutputLayer.Neurons).Concat(HiddenLayers.SelectMany(x => x.Neurons)).ToList();

            this.Synapses = InputLayer.Neurons.SelectMany(x => x.OutgoingSynapses ?? new ISynapse[0]).ToList();

            foreach (var hiddenLayer in HiddenLayers)
            {
                this.Synapses.Concat(hiddenLayer.Neurons.SelectMany(x => x.OutgoingSynapses));
            }

            //Synapses won't be added twice since we only collect outgoing synapses
            //this.Synapses = this.Synapses.Distinct().ToList();
        }