Threshold activation function.

The class represents threshold activation function with the next expression: f(x) = 1, if x >= 0, otherwise 0

Output range of the function: [0, 1].

Functions graph:

Inheritance: IActivationFunction
コード例 #1
0
ファイル: Program.cs プロジェクト: Vilozio/Neuro-network
        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();
        }
コード例 #2
0
        public NetworkContainer CreateNetworkContainer()
        {
            NetworkContainer neuralNetwork = null;

            int[] hiddenLayers = new int[cbHiddenLayerNumber.SelectedIndex];

            switch (hiddenLayers.Length)
            {
                case 0:
                    break;
                case 1:
                    hiddenLayers[0] = (int)this.nHidden1.Value;
                    break;
                case 2:
                    hiddenLayers[1] = (int)this.nHidden2.Value;
                    goto case 1;
                case 3:
                    hiddenLayers[2] = (int)this.nHidden3.Value;
                    goto case 2;
                case 4:
                    hiddenLayers[3] = (int)this.nHidden4.Value;
                    goto case 3;
                default:
                    break;
            }

            IActivationFunction activationFunction = null;

            if (this.rbBipolarSigmoid.Checked)
            {
                activationFunction = new BipolarSigmoidFunction((double)numSigmoidAlpha.Value);
            }
            else if (this.rbSigmoid.Checked)
            {
                activationFunction = new SigmoidFunction((double)numSigmoidAlpha.Value);
            }
            else if (this.rbThreshold.Checked)
            {
                activationFunction = new ThresholdFunction();
            }

            neuralNetwork = new NetworkContainer(
                    tbNetworkName.Text,
                    m_networkSchema,
                    activationFunction,
                    hiddenLayers);

             //         neuralNetwork.Schema.DataRanges.ActivationFunctionRange = new AForge.DoubleRange((double)numRangeLow.Value, (double)numRangeHigh.Value);

            return neuralNetwork;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Vilozio/Neuro-network
        void Proc1()
        {
            int learnIterations = 100;
            double desiredError = 0;

            Model model = getModelAnd();
            var activationFunc1 = new ThresholdFunction();
            var activationFunc2 = new SigmoidFunction(1);
            IActivationFunction activationFunc = activationFunc2;
            int inputsCount = model.InputsCount;
            int neuronsCount = 1;

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

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

            Console.ReadLine();
        }