Exemplo n.º 1
0
            public void execute()
            {
                double sum    = 0.0;
                double output = 0.0;

                object[] fromLinks = this.getFromLinks().ToArray();

                for (int inputLinksCount = 0; inputLinksCount < fromLinks.Length; inputLinksCount++)
                {
                    sum += ((Link)fromLinks[inputLinksCount]).getWeight() * ((Link)fromLinks[inputLinksCount]).getInputValue();
                }
                sum = sum + this.bias;

                if (transferFunction == 1)
                {
                    output = (1 + Math.Exp(-sum));
                    output = 1 / output;
                }
                if (transferFunction == 2)
                {
                    //n = 2/(1+exp(-2*n))-1 TANSIG
                    output = 2 / (1 + Math.Exp(-2 * sum)) - 1;
                }


                object[] toLinks = this.getToLinks().ToArray();

                for (int outputLinksCount = 0; outputLinksCount < toLinks.Length; outputLinksCount++)
                {
                    ((Link)toLinks[outputLinksCount]).setInputValue(output);
                }

                if (this.GetType().ToString() == "Neurotic.NeuralNet+OutputNeuron")
                {
                    NeuralNet.OutputNeuron n = (NeuralNet.OutputNeuron) this;
                    n.setOutputValue(output);
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>

        public float[] getNNOutput(int denormType) // denormType 0 (NO Denorm) OR 1(0~1) OR 2 (-1~1)
        {
            int numOutputs = net.getLayer(net.layers.Count - 1).getNeuronCount();

            float[] f = new float[numOutputs];
            for (int count = 0; count < numOutputs; count++)
            {
                NeuralNet.Layer        layer = net.getLayer(net.layers.Count - 1);
                NeuralNet.OutputNeuron o     = (NeuralNet.OutputNeuron)layer.getNeuron(count);
                f[count] = (float)Convert.ToDecimal((o.getOutputValues())[0]);
            }
            if (denormType == 0)
            {
                return(f);
            }
            else if (denormType == 1)
            {
                return(Denormalize(f, true));
            }
            else
            {
                return(Denormalize(f, false));
            }
        }