Ejemplo n.º 1
0
        static Model getModelAnd()
        {
            if (modelAnd == null) {
                int sampleCount = 4;
                int inputsCount = 2;
                int outputsCount = 1;
                double[][] input;
                double[][] desiredOutput;

                input = new double[sampleCount][];
                desiredOutput = new double[sampleCount][];
                for (int i = 0; i < input.Length; i++) {
                    input[i] = new double[inputsCount];
                    desiredOutput[i] = new double[outputsCount];
                }
                input[0][0] = 0;
                input[0][1] = 0;
                input[1][0] = 0;
                input[1][1] = 1;
                input[2][0] = 1;
                input[2][1] = 0;
                input[3][0] = 1;
                input[3][1] = 1;

                desiredOutput[0][0] = 0;
                desiredOutput[1][0] = 1;
                desiredOutput[2][0] = 1;
                desiredOutput[3][0] = 1;

                modelAnd = new Model(inputsCount, input, desiredOutput);
            }
            return modelAnd;
        }
Ejemplo n.º 2
0
        void Proc2(Model model)
        {
            int learnIterations = 100;
            double desiredError = 0;

            var activationFunc1 = new ThresholdFunction();
            var activationFunc2 = new SigmoidFunction(1);
            IActivationFunction activationFunc = activationFunc2;
            int inputsCount = model.InputsCount;
            int[] neuronsCount = new int[3];
            neuronsCount[0] = model.InputsCount;
            neuronsCount[1] = model.InputsCount * 2;
            neuronsCount[2] = model.desiredOutput[0].Length;

            ActivationNetwork net = new ActivationNetwork(activationFunc, inputsCount, neuronsCount);
            BackPropagationLearning lerning = new BackPropagationLearning(net);
            ErrorCalculator errorCalculator = new ErrorCalculator();

            Process(learnIterations, desiredError, net, lerning,
                model.input, model.desiredOutput, errorCalculator);

            Console.ReadLine();
        }