Ejemplo n.º 1
0
        public AWindow(IWindow owner)
            : base(owner, Core.settings)
        {
            TabItem from_me = new TabItem();
            from_me.BeginInit();
            from_me.EndInit();
            this.Background = from_me.Background;
            ProgressBar from_color = new ProgressBar();
            default_progress_color = from_color.Foreground;

            // Taskbar progress setup
            TaskbarItemInfo = new TaskbarItemInfo();
            //            var uriSource = new Uri(System.IO.Path.Combine(Core.ExecutablePath, "masgau.ico"), UriKind.Relative);

            System.Drawing.Icon ico = Properties.Resources.MASGAUIcon;

            this.Icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    ico.ToBitmap().GetHbitmap(),
                    IntPtr.Zero,
                    Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());

            if (owner != null) {
                this.Owner = owner as System.Windows.Window;
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            } else {
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            }
        }
Ejemplo n.º 2
0
        private void RefreshWeightsView()
        {
            if (designPageViewModel.TabItems != null)
                designPageViewModel.TabItems.Clear();
            else
                designPageViewModel.TabItems = new ObservableCollection<TabItem>();

            foreach (Layers layer in pageViewModel.NeuralNetwork.Layers)
            {
                if (layer.LayerType == LayerTypes.Convolutional || layer.LayerType == LayerTypes.ConvolutionalSubsampling)
                {
                    TabItem tb = new TabItem();
                    tb.BeginInit();
                    tb.UseLayoutRounding = true;
                    tb.SnapsToDevicePixels = true;
                    tb.Header = layer.LayerIndex.ToString();
                    tb.Content = layer.GetMappedLayerWeights();
                    tb.EndInit();
                    designPageViewModel.TabItems.Add(tb);
                }
            }

            needRefreshWeightsView = false;
        }
Ejemplo n.º 3
0
        private void Calculate()
        {
            (MainView.DataContext as PageViewModel).CommandToolBar[0].IsEnabled = false;
            calculatePageViewModel.IsValid = false;
            MainView.Status.Text = "Calculating...";

            Mouse.OverrideCursor = Cursors.Wait;
            DoubleImageData pattern;

            if (calculatePageViewModel.UseTrainingSet)
            {
                if (calculatePageViewModel.UseDistortions)
                {
                    pageViewModel.DataProvider.SeverityFactor = calculatePageViewModel.SeverityFactor;
                    pageViewModel.DataProvider.MaxRotation = calculatePageViewModel.MaxRotation;
                    pageViewModel.DataProvider.MaxScaling = calculatePageViewModel.MaxScaling;
                    pageViewModel.DataProvider.ElasticScaling = calculatePageViewModel.ElasticScaling;
                    pageViewModel.DataProvider.ElasticSigma = calculatePageViewModel.ElasticSigma;
                    pageViewModel.DataProvider.CalculateGaussianKernel();

                    pattern = new DoubleImageData(pageViewModel.DataProvider.TrainingPatterns[calculatePageViewModel.PatternIndex].Label, pageViewModel.DataProvider.GetDistortedPattern(calculatePageViewModel.PatternIndex, true));
                }
                else
                    pattern = pageViewModel.DataProvider.TrainingPatterns[calculatePageViewModel.PatternIndex];
            }
            else
            {
                if (calculatePageViewModel.UseDistortions)
                {
                    pageViewModel.DataProvider.SeverityFactor = calculatePageViewModel.SeverityFactor;
                    pageViewModel.DataProvider.MaxRotation = calculatePageViewModel.MaxRotation;
                    pageViewModel.DataProvider.MaxScaling = calculatePageViewModel.MaxScaling;
                    pageViewModel.DataProvider.ElasticScaling = calculatePageViewModel.ElasticScaling;
                    pageViewModel.DataProvider.ElasticSigma = calculatePageViewModel.ElasticSigma;
                    pageViewModel.DataProvider.CalculateGaussianKernel();

                    pattern = new DoubleImageData(pageViewModel.DataProvider.TestingPatterns[calculatePageViewModel.PatternIndex].Label, pageViewModel.DataProvider.GetDistortedPattern(calculatePageViewModel.PatternIndex, false));
                }
                else
                    pattern = pageViewModel.DataProvider.TestingPatterns[calculatePageViewModel.PatternIndex];
            }

            Layers firstLayer = pageViewModel.NeuralNetwork.Layers.First();
            for (int i = 0; i < pageViewModel.DataProvider.PatternSize; ++i)
            {
                //pattern[i] = ((pattern[i] * 0.6375D) + 0.5375D); // normalization (-0.1 --> 1.175)
                firstLayer.Neurons[i].Output = pattern.Image[i];
            }

            string result = String.Empty;
            result += "Input: " + pattern.Label.ToString() + "\r\n";

            int bestIndex = 0;
            System.Diagnostics.Stopwatch timer = new Stopwatch();
            timer.Restart();
            pageViewModel.NeuralNetwork.Calculate();
            bestIndex = Recognised();
            timer.Stop();

            result += "\r\n";
            Layers lastLayer = pageViewModel.NeuralNetwork.Layers.Last();
            for (int i = 0; i < lastLayer.NeuronCount; i++)
            {
                result += i.ToString() + " ==> " + lastLayer.Neurons[i].Output.ToString("N17") + "\r\n";
            }
            result += "\r\n";

            double patternMSE = GetPatternMSE(pattern.Label);
            result += "Pattern MSE: " + patternMSE.ToString("N17") + "\r\n";

            result += "Highest prob: " + bestIndex.ToString() + "\r\n";
            if (bestIndex == pattern.Label)
                result += "Correctly recognized";
            else
                result += "Not correctly recognized";

            result += "\r\nTime: " + timer.ElapsedMilliseconds.ToString() + " ms.";

            calculatePageViewModel.Result = result;

            calculatePageViewModel.TabItems = new ObservableCollection<TabItem>();

            foreach (Layers layer in pageViewModel.NeuralNetwork.Layers)
            {
                if (layer.UseMapInfo)
                {
                    TabItem tb = new TabItem();
                    tb.BeginInit();
                    tb.UseLayoutRounding = true;
                    tb.SnapsToDevicePixels = true;
                    tb.Header = layer.LayerIndex.ToString();
                    tb.Content = layer.GetMappedLayerOutputs();
                    tb.EndInit();
                    calculatePageViewModel.TabItems.Add(tb);
                }
            }

            Mouse.OverrideCursor = null;

            MainView.Status.Text = "Ready";
            calculatePageViewModel.IsValid = true;
            (MainView.DataContext as PageViewModel).CommandToolBar[0].IsEnabled = true;
        }
Ejemplo n.º 4
0
        public AWindow(AWindow owner)
            : base()
        {
            TabItem from_me = new TabItem();
            from_me.BeginInit();
            from_me.EndInit();
            this.Background = from_me.Background;
            ProgressBar from_color = new ProgressBar();
            default_progress_color = from_color.Foreground;

            // Taskbar progress setup
            TaskbarItemInfo = new TaskbarItemInfo();
            var uriSource = new Uri(System.IO.Path.Combine(Core.app_path,"masgau.ico"), UriKind.Relative);
            this.Icon = new BitmapImage(uriSource);
            if(owner!=null) {
                this.Owner = owner;
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            } else {
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            }

            // Jumplist setup
            JumpList masgau_jump_list = JumpList.GetJumpList(Application.Current);
            if(masgau_jump_list==null) {
                masgau_jump_list = new JumpList();
                JumpList.SetJumpList(Application.Current, masgau_jump_list);
            } else {
                masgau_jump_list.JumpItems.Clear();
                masgau_jump_list.ShowFrequentCategory = false;
                masgau_jump_list.ShowRecentCategory = false;

            }

            JumpTask masgau_jump = new JumpTask();
            masgau_jump.ApplicationPath = Path.Combine(Core.app_path,"MASGAU.Main.WPF.exe");
            masgau_jump.IconResourcePath = Path.Combine(Core.app_path,"masgau.ico");
            masgau_jump.WorkingDirectory = Core.app_path;
            masgau_jump.Title = "Main Program";
            masgau_jump.Description = "Open MASGAU's Main Window";
            masgau_jump.CustomCategory = "MASGAU";
            masgau_jump_list.JumpItems.Add(masgau_jump);

            masgau_jump = new JumpTask();
            masgau_jump.ApplicationPath = Path.Combine(Core.app_path,"MASGAU.Main.WPF.exe");
            masgau_jump.IconResourcePath = Path.Combine(Core.app_path,"masgau.ico");
            masgau_jump.WorkingDirectory = Core.app_path;
            masgau_jump.Title = "Main Program (All Users Mode)";
            masgau_jump.Description = "Open MASGAU's Main Window In All Users Mode";
            masgau_jump.Arguments = "-allusers";
            masgau_jump.CustomCategory = "MASGAU";
            masgau_jump_list.JumpItems.Add(masgau_jump);

            masgau_jump = new JumpTask();
            masgau_jump.ApplicationPath = Path.Combine(Core.app_path,"MASGAU.Analyzer.WPF.exe");
            masgau_jump.IconResourcePath = Path.Combine(Core.app_path,"masgau.ico");
            masgau_jump.WorkingDirectory = Core.app_path;
            masgau_jump.Title = "Analyzer";
            masgau_jump.Description = "Open MASGAU's Save Game Analyzer";
            masgau_jump.CustomCategory = "MASGAU";
            masgau_jump_list.JumpItems.Add(masgau_jump);

            masgau_jump = new JumpTask();
            masgau_jump.ApplicationPath = Path.Combine(Core.app_path,"MASGAU.Monitor.WPF.exe");
            masgau_jump.IconResourcePath = Path.Combine(Core.app_path,"masgau.ico");
            masgau_jump.WorkingDirectory = Core.app_path;
            masgau_jump.Title = "Monitor";
            masgau_jump.Description = "Open MASGAU's Monitor";
            masgau_jump.CustomCategory = "MASGAU";
            masgau_jump_list.JumpItems.Add(masgau_jump);

            masgau_jump_list.Apply();

            //These intitialize the contexts of the CommunicationHandlers
            if(SynchronizationContext.Current == null)
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(this.Dispatcher));
            _context = SynchronizationContext.Current;

            CommunicationHandler.addReceiver(this);

            this.Closing += new CancelEventHandler(Window_Closing);
        }