コード例 #1
0
        public NeuralNetwork(NeuronCount inputs, NeuronCount[] numberOfNeuronsPerHiddenLayer, NeuronCount outputs)
        {
            layers = new[] { inputs }
            .Concat(numberOfNeuronsPerHiddenLayer)
            .Concat(new[] { outputs })
            .Select(n => new NeuralNetworkLayer(n))
            .ToArray();

            for (var i = layers.Length - 1; i > 1; i--)
            {
                ((INeuralNetworkLayer)layers[i]).BuildSynapses(layers[i - 1]);
            }
        }
コード例 #2
0
        public NeuralNetwork(NeuronCount inputs, NeuronCount outputs, params NeuronCount[] hiddenLayers)
        {
            if (hiddenLayers == null || !hiddenLayers.Any())
            {
                throw new ArgumentException("At least one hidden layer is required", nameof(hiddenLayers));
            }

            NeuralNetworkLayer previousLayer = null;

            layers = new[] { inputs }
            .Concat(hiddenLayers)
            .Concat(new[] { outputs })
            .Select(nc =>
            {
                previousLayer = previousLayer == null ? new NeuralNetworkLayer(nc) : new NeuralNetworkLayer(nc, previousLayer);
                return(previousLayer);
            })
            .ToArray();
        }
コード例 #3
0
 public NeuralNetworkLayer(NeuronCount numberOfNeurons)
 {
     neurons = Enumerable.Range(1, numberOfNeurons)
               .Select(_ => new Neuron())
               .ToArray();
 }