Beispiel #1
0
        public float[] pullOutputs()
        {
            ListIterator <NetworkNode> iterhidden1 = new  ListIterator <NetworkNode>(hlayer1);
            ListIterator <NetworkNode> iterhidden2 = new ListIterator <NetworkNode>(hlayer2);
            ListIterator <NetworkNode> iterout     = new  ListIterator <NetworkNode>(outlayer);

            while (iterhidden1.hasNext())
            {
                iterhidden1.next().Value.UpdateOutput();
            }

            while (iterhidden2.hasNext())
            {
                iterhidden2.next().Value.UpdateOutput();
            }

            while (iterout.hasNext())
            {
                iterout.next().Value.UpdateOutput();
            }
            ListIterator <NetworkNode> iterfinal = new ListIterator <NetworkNode>(outlayer);
            int i = 0;

            float[] barray = new float[4];
            while (iterfinal.hasNext())
            {
                NetworkNode bob = iterfinal.next().Value;
                barray[i] = (bob.getOutput()) > 0.6f?1:0;
                i++;
            }
            return(barray);
        }
Beispiel #2
0
        public void pushInputs(float[] farray)
        {
            ListIterator <InNetworkNode> iter = new ListIterator <InNetworkNode>(this.inlayer);
            int i = 0;

            while (iter.hasNext())
            {
                InNetworkNode bob = iter.next().Value;
                bob.setOutput(farray[i]);
                i++;
            }
        }
Beispiel #3
0
        public void UpdateOutput()
        {
            float max = 0.0f;

            this.output = 0.0f;
            ListIterator <NetworkNode> nodes = new ListIterator <NetworkNode>(dependancies);
            ListIterator <float>       vals  = new ListIterator <float>(weights);

            while (nodes.hasNext())
            {
                output += vals.next().Value *nodes.next().Value.getOutput();
                max    += 1.0f;
            }
            //output /= max;
            // output *= 2.0f;
            output = (float)Math.Tanh(output);

            this.dirty = false;
        }
Beispiel #4
0
        public void reinforceNode(float type)
        {
            ListIterator <NetworkNode> nodes = new ListIterator <NetworkNode>(dependancies);
            ListIterator <float>       vals  = new ListIterator <float>(weights);

            while (nodes.hasNext())
            {
                float value = vals.next().Value *nodes.next().Value.getOutput();
                if (value > 0.6)
                {
                    vals.current().Value += type;
                }
                else
                {
                    vals.current().Value -= type;
                }

                if (vals.current().Value > 1.0f)
                {
                    vals.current().Value = 1.0f;
                }
                if (vals.current().Value < -1.0f)
                {
                    vals.current().Value = -1.0f;
                }
                //type *= -1;
                if (nodes.current().Value.getOutput() > 0.6 && !(nodes.current().Value is InNetworkNode))
                {
                    nodes.current().Value.reinforceNode(type / 2);
                }
                else
                {
                    nodes.current().Value.reinforceNode(-type / 2);
                }
            }
        }