示例#1
0
            private void RecalculateNetwork(NetNeural xNet)
            {
                //RECALCULATE NETWORK
                int nodesInput  = xNet.NodesInput;
                int nodesHidden = xNet.NodesHidden;
                int nodesOutput = xNet.NodesOutput;

                //PANEL
                PanelTop    = new int[] { 0, (int)Start * 2, Panel.Height - (int)Start * 2 };
                PanelHeight = PanelTop[2] - PanelTop[1];
                PanelCenter = PanelHeight / 2 + PanelTop[1];
                PanelMax    = PanelHeight / NodesHeight;
                PanelRatio  = new float[] { nodesInput / PanelMax, nodesHidden / PanelMax, nodesOutput / PanelMax };
                for (int i = 0; i < PanelRatio.Length; i++)
                {
                    if (PanelRatio[i] < 1)
                    {
                        PanelRatio[i] = 1;
                    }
                }

                //NODES
                Count = new int[] { (int)(nodesInput / PanelRatio[0]), (int)(nodesHidden / PanelRatio[1]), (int)(nodesOutput / PanelRatio[2]) };
                float[] space = new float[] { Count[0] * NodesHeight, Count[1] * NodesHeight, Count[2] * NodesHeight };
                Area = new float[] { PanelCenter - space[0] / 2, PanelCenter - space[1] / 2, PanelCenter - space[2] / 2 };

                //TEXTS
                Caption = new string[] { "Input Nodes (" + nodesInput + ")", "Hidden Nodes (" + nodesHidden + ")", "Output Nodes (" + nodesOutput + ")" };
                Factor  = new string[] { Mod_Convert.DoubleFormat(PanelRatio[0], 2) + "x", Mod_Convert.DoubleFormat(PanelRatio[1], 2) + "x", Mod_Convert.DoubleFormat(PanelRatio[2], 2) + "x" };

                //LIST
                PointList = new List <PointF[]>();
            }
示例#2
0
        public void Run()
        {
            //CHECK TABLE TRAIN
            if (NetMain.TableTrain.RowCount == 0)
            {
                NetMain.setConsoleInvoke("No items in table"); NetMain.ToggleSim.Checked = false;
            }

            //ABBRUCH
            if (!NetMain.ToggleSim.Checked)
            {
                return;
            }

            //LEARNING RATE
            LRmin   = (double)SpinLRmin.Value;
            LRmax   = (double)SpinLRmax.Value;
            LRdelta = (double)SpinLRdelta.Value;
            LRnow   = (double)SpinLRnow.Value;

            //EPOCHS
            Emin   = SpinEmin.getInteger();
            Emax   = SpinEmax.getInteger();
            Edelta = SpinEdelta.getInteger();
            Enow   = SpinEnow.getInteger();

            Net             = NetMain.Net;
            NetMain.Content = NetMain.TableTrain.ToStringArray(NetMain.MainSplit);
            SimNext();
        }
示例#3
0
            public void Plot(Graphics g)
            {
                //PLOT
                Net = Main.Net;

                //ABBRUCH
                if (Net == null)
                {
                    return;
                }

                //RECALCULATE PARAMETERS
                RecalculateNetwork(Net);

                //LOOP NODES
                for (int i = 0; i < Count.Length; i++)
                {
                    //DRAW CAPTION
                    int strWidth = Mod_Convert.StringToWidth(Caption[i], DrawFont) / 2;
                    g.DrawString(Caption[i], DrawFont, Brush, NodesLeft[i] - strWidth, PanelTop[0]);

                    Current = Area[i];
                    List <PointF> tempList = new List <PointF>();

                    //DRAW NODES
                    for (int node = 0; node < Count[i]; node++)
                    {
                        tempList.Add(new PointF(NodesLeft[i], Current));
                        g.DrawEllipse(PenNode, NodesLeft[i] - Radius, Current - Radius, Radius + Radius, Radius + Radius);
                        Current = Current + NodesNext[i];
                    }

                    PointList.Add(tempList.ToArray());

                    //DRAW SCALE
                    strWidth = Mod_Convert.StringToWidth(Factor[i], DrawFont) / 2;
                    g.DrawString(Factor[i], DrawFont, Brush, NodesLeft[i] - strWidth, PanelTop[2]);
                }

                double maxInput  = getAbsMax(Net.weightInput);
                double maxOutput = getAbsMax(Net.weightOutput);

                //DRAW LINES
                foreach (PointF pt1 in PointList[0])
                {
                    foreach (PointF pt2 in PointList[1])
                    {
                        int    x      = (int)(Array.IndexOf(PointList[0], pt1) * PanelRatio[0]);
                        int    y      = (int)(Array.IndexOf(PointList[1], pt2) * PanelRatio[1]);
                        double weight = Math.Abs(Net.weightInput[y, x]);
                        PenLine = getPen(weight / maxInput);
                        if (PenLine.Color.A > Alpha)
                        {
                            g.DrawLine(PenLine, pt1, pt2); //INPUT TO HIDDEN
                        }
                        foreach (PointF pt3 in PointList[2])
                        {
                            int z = (int)(Array.IndexOf(PointList[2], pt3) * PanelRatio[2]);
                            weight  = Math.Abs(Net.weightOutput[z, y]);
                            PenLine = getPen(weight / maxOutput);
                            if (PenLine.Color.A > Alpha)
                            {
                                g.DrawLine(PenLine, pt2, pt3); //HIDDEN TO OUTPUT
                            }
                        }
                    }
                }
            }