private void InitializeNetwork()
        {
            IsLearningRightNow = false;
            wpfGraphics.Clear();

            X = new double[10000, 2];
            Y = new double[10000, 3];


            for (int x = 0; x < 100; x++)
            {
                for (int y = 0; y < 100; y++)
                {
                    X[x * 100 + y, 0] = (double)(((double)(x - 50)) / 50);
                    X[x * 100 + y, 1] = (double)(((double)(y - 50)) / 50);
                    Y[x * 100 + y, 0] = getDouble((GetPixelColor(TestBitmap, x, y).R));
                    Y[x * 100 + y, 1] = getDouble((GetPixelColor(TestBitmap, x, y).G));
                    Y[x * 100 + y, 2] = getDouble((GetPixelColor(TestBitmap, x, y).B));
                }
            }

            Layer[] layers = new Layer[2 + HiddenLayers.Count()];
            layers[0] = new Layer(LayerType.Input, X, ActivationFunction.RELU);

            for (int i = 1; i < HiddenLayers.Count() + 1; i++)
            {
                layers[i] = HiddenLayers[i - 1];
            }

            layers[layers.Count() - 1] = new Layer(LayerType.Output, Y, ActivationFunction.Tanh);
            nn = new NEngine(layers, Y, LearningRate, 0, BatchSize);
            nn.ForwardPropagation();
        }
Esempio n. 2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!m_OpenFileMode)
     {
         NResourceLoc loc = GetResourceLocation();
         if (NEngine.Instance().FileSystem.IsFileExist(loc.PackageName, loc.FileName))
         {
             DialogResult rst = MessageBox.Show("当前名称的文件已经存在,是否覆盖?", "警告", MessageBoxButtons.YesNo);
             if (rst != DialogResult.Yes)
             {
                 return;
             }
             else
             {
                 DialogResult = DialogResult.OK;
                 this.Close();
             }
         }
         else
         {
             DialogResult = DialogResult.OK;
             this.Close();
         }
     }
     else
     {
         DialogResult = DialogResult.OK;
         this.Close();
     }
 }
Esempio n. 3
0
        private void AddNewPoint(MouseButton mb)
        {
            IsLearningRightNow = false;
            Point p = new Point(PanelX, PanelY);

            if (mb == MouseButton.Left)
            {
                BluePoint.Add(p);
            }
            else
            {
                OrangePoint.Add(p);
            }

            wpfGraphics.Clear();

            DrawPoints();

            double[,] X = new double[BluePoint.Count() + OrangePoint.Count(), 2];
            double[,] Y = new double[BluePoint.Count() + OrangePoint.Count(), 2];

            for (int i = 0; i < BluePoint.Count(); i++)
            {
                X[i, 0] = BluePoint[i].X / 300;
                X[i, 1] = BluePoint[i].Y / 300;
                Y[i, 0] = 1;
                Y[i, 1] = -1;
            }

            for (int i = BluePoint.Count(); i < BluePoint.Count() + OrangePoint.Count(); i++)
            {
                X[i, 0] = (OrangePoint[i - BluePoint.Count()].X / 300);
                X[i, 1] = (OrangePoint[i - BluePoint.Count()].Y / 300);
                Y[i, 0] = -1;
                Y[i, 1] = 1;
            }
            MatrixExtensions.Unsort(ref X, ref Y);

            X.SplitMatrix(out X2, out TestX, LearnToTest);
            Y.SplitMatrix(out Y2, out TestY, LearnToTest);


            Layer[] layers = new Layer[2 + HiddenLayers.Count()];

            layers[0] = new Layer(LayerType.Input, X2, ActivationFunction.Tanh);

            for (int i = 1; i < HiddenLayers.Count() + 1; i++)
            {
                layers[i] = HiddenLayers[i - 1];
            }

            layers[layers.Count() - 1] = new Layer(LayerType.Output, Y2, ActivationFunction.Tanh);

            nn = new NEngine(layers, Y2, LearningRate, 0);

            nn.ForwardPropagation().Print();
        }
        /// <summary>
        /// 引擎Callback函数
        /// </summary>
        /// <param name="file">文件对象描述</param>
        public override void OnFileEntity(ref NFileEntity file)
        {
            if (file.type == EFileEntityType.Regular)
            {
                bool add = true;
                if (m_filter != null)
                {
                    add = m_filter.FileEnabled(file);
                }

                if (add)
                {
                    ListViewItem it        = m_listCtrl.Items.Add(file.FileName);
                    string       thumbName =
                        ThumbnailManager.Instance.LoadThumbnail(file.PackageName, file.FilePath,
                                                                m_imgList, m_imgListSmall);

                    uint     fileSize = NEngine.Instance().FileSystem.GetFileSize(file.PackageName, file.FilePath);
                    DateTime fileTime = NEngine.Instance().FileSystem.GetFileTime(file.PackageName, file.FilePath);

                    it.ImageKey = thumbName;
                    it.Tag      = file;

                    //-- sub item [file size]
                    string strFileSize;
                    if (fileSize > 1024)
                    {
                        strFileSize = string.Format("{0}KB", fileSize / 1024);
                    }
                    else
                    {
                        strFileSize = fileSize.ToString();
                    }
                    it.SubItems.Add(strFileSize);

                    //-- sub item [resource type]
                    it.SubItems.Add(GetResourceTypeByFileExt(file.FileExtension));

                    //-- sub item [file time]
                    string strFileTime = string.Format("{0} {1}",
                                                       fileTime.ToShortDateString(), fileTime.ToShortTimeString());
                    it.SubItems.Add(strFileTime);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 初始化GUI系统,在InitModules时调用
        /// </summary>
        private void InitGuiSystem()
        {
            NRenderResourceManager renderResMgr = NEngine.Instance().RenderResManager;

            guiCanvas = renderResMgr.NewUICanvas();

            // 创建UI系统
            new GUISystem(guiCanvas);

            //加载程序集,注册内置窗口类型
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

            WindowManager.Instance.LoadAssembly(Path.GetDirectoryName(executingAssembly.Location) + System.IO.Path.DirectorySeparatorChar + @"Nexus.GUI.dll");
            // 加载当前执行文件中窗口类型
            WindowManager.Instance.AttachAssembly(executingAssembly);
            WindowManager.Instance.AttachAssembly(Assembly.GetEntryAssembly());
            // 创建一个缺省的唯一父窗口
            GUISystem.Instance.RootWindow = WindowManager.Instance.CreateWindow("Nexus.GUI.Widgets.GUISheet", GUISystem.DefaultRootWindowName, null);
        }
Esempio n. 6
0
        /// <summary>
        /// 窗口大小发生变化
        /// </summary>
        protected virtual void GameViewportControl_SizeChanged(object sender, EventArgs e)
        {
            NEngineConfig eng = NEngine.Instance().Config;

            gameViewport.Width  = (uint)Math.Min(eng.ClientWidth, this.ClientSize.Width);
            gameViewport.Height = (uint)Math.Min(eng.ClientHeight, this.ClientSize.Height);
            gameViewport.X      = (uint)(eng.ClientWidth - gameViewport.Width) / 2;
            gameViewport.Y      = (uint)(eng.ClientHeight - gameViewport.Height) / 2;
            gameViewport.Camera.SetPerspective(gameViewport.Camera.FOV,
                                               Math.Min(this.ClientSize.Width, eng.ClientWidth),
                                               Math.Min(this.ClientSize.Height, eng.ClientHeight),
                                               10, 50000);
            gameViewport.Update();

            Window rootWnd = GUISystem.Instance == null ? null : GUISystem.Instance.RootWindow;

            if (rootWnd != null)
            {
                rootWnd.AbsolutePosition = new Vector2(gameViewport.X, gameViewport.Y);
                rootWnd.AbsoluteSize     = new Vector2(gameViewport.Width, gameViewport.Height);
            }
        }
Esempio n. 7
0
        public NGUIWidgetsRender()
        {
            NRenderResourceManager renderResMgr = NEngine.Instance().RenderResManager;

            m_uiCanvas = renderResMgr.NewUICanvas();
        }