예제 #1
0
        public NeuralNetwork(
            ActivationFunction activationFunction,
            double initialWeightsRange,
            params int[] sizes
            )
        {
            Sizes      = sizes;
            InputLayer = new InputLayer();

            HiddenLayers = new HiddenLayer[sizes.Length - 2];

            for (var i = 0; i < sizes.Length - 2; i++)
            {
                //var isLast = i == sizes.Length - 1;
                HiddenLayers[i] = new HiddenLayer(
                    sizes[i],
                    sizes[i + 1],
                    activationFunction,
                    initialWeightsRange);
            }

            var length = sizes.Length;

            OutputLayer = new OutputLayer(
                sizes[length - 2],
                sizes[length - 1],
                activationFunction,
                initialWeightsRange);
        }
예제 #2
0
        public new Vector <double> Compute(Vector <double> input)
        {
            input = InputLayer.Feedforward(input);

            foreach (var layer in HiddenLayers)
            {
                input = layer.Feedforward(input);
            }

            var decision = OutputLayer.Feedforward(input);

            return(decision);
        }