Exemplo n.º 1
0
        public static T CreateBrain <T>(BrainFactoryInput input) where T : Brain.Brain
        {
            var nNetwork = new Brain.NeuralNetwork(input.ActivationFunctionInputOutput, input.ActivationFunctionHiddenLayers,
                                                   input.Inputs, input.Outputs, input.HiddenLayers, input.NeuronsPerHiddenLayer, input.Alpha);

            return((T)Activator.CreateInstance(typeof(T), nNetwork));
        }
Exemplo n.º 2
0
        private static void TrainNeuralNetwork()
        {
            var input = new BrainFactoryInput()
            {
                ActivationFunctionInputOutput  = new Sigmoid(),
                ActivationFunctionHiddenLayers = new Sigmoid(), //do not use TanH for the xorbrain it is counter productive.  The xor needs 0 or 1, TanH brings in negative values as well
                Inputs                = 2,
                Outputs               = 1,
                HiddenLayers          = 1,
                NeuronsPerHiddenLayer = 2,
                Alpha = 0.8 //how much impact the training has, sometimes you'll see NaN come back and this dials back the calculations a bit
            };
            var brain = BrainFactory.CreateBrain <XorBrain>(input);

            brain.Think(trainingIterations: 1000);
        }