Esempio n. 1
0
        public ScrollViewer GetMappedLayerWeights()
        {
            WrapPanel panel = new WrapPanel();
            panel.BeginInit();
            panel.UseLayoutRounding = true;
            panel.SnapsToDevicePixels = true;
            panel.Orientation = Orientation.Horizontal;
            panel.HorizontalAlignment = HorizontalAlignment.Stretch;
            panel.VerticalAlignment = VerticalAlignment.Stretch;

            for (int map = 0; map < MapCount; map++)
            {
                Grid grid = new Grid();
                grid.SnapsToDevicePixels = true;
                grid.UseLayoutRounding = true;
                grid.Background = System.Windows.Media.Brushes.White;
                grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                grid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                grid.Width = double.NaN;
                grid.Height = double.NaN;
                grid.Margin = new Thickness(4);

                for (int col = 0; col < MapWidth; col++)
                {
                    ColumnDefinition colDef = new ColumnDefinition();
                    colDef.Width = new GridLength(0, GridUnitType.Auto);
                    grid.ColumnDefinitions.Add(colDef);
                }
                for (int row = 0; row < MapHeight; row++)
                {
                    RowDefinition rowDef = new RowDefinition();
                    rowDef.Height = new GridLength(0, GridUnitType.Auto);
                    grid.RowDefinitions.Add(rowDef);
                }

                double weightMin = Weights.Min(weight => weight.Value);
                double weightMax = Weights.Max(weight => weight.Value);
                double range = GetRangeFactor(weightMin, weightMax);

                grid.BeginInit();
                for (int y = 0; y < ReceptiveFieldWidth; y++)
                {
                    for (int x = 0; x < ReceptiveFieldHeight; x++)
                    {
                        int index = x + (y * ReceptiveFieldWidth) + (map * ((ReceptiveFieldWidth * ReceptiveFieldHeight) + 1));
                        System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
                        rectangle.BeginInit();
                        rectangle.SnapsToDevicePixels = true;
                        rectangle.UseLayoutRounding = true;
                        rectangle.HorizontalAlignment = HorizontalAlignment.Stretch;
                        ToolTip tip = new ToolTip();
                        tip.Content = Weights[index].Value.ToString("N17", CultureInfo.CurrentUICulture);
                        rectangle.ToolTip = tip;
                        rectangle.VerticalAlignment = VerticalAlignment.Stretch;
                        rectangle.Margin = new Thickness(0);
                        rectangle.Height = 8;
                        rectangle.Width = 8;
                        rectangle.Stretch = Stretch.Uniform;
                        rectangle.Fill = GetBrushFromRange(range, weightMin, weightMax, Weights[index].Value);
                        rectangle.EndInit();
                        Grid.SetColumn(rectangle, x);
                        Grid.SetRow(rectangle, y);
                        grid.Children.Add(rectangle);
                        tip = null;
                        rectangle = null;
                    }
                };

                grid.EndInit();
                panel.Children.Add(grid);
            }
            panel.EndInit();

            ScrollViewer scr = new ScrollViewer();
            scr.BeginInit();
            scr.SnapsToDevicePixels = true;
            scr.UseLayoutRounding = true;
            scr.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
            scr.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            scr.HorizontalContentAlignment = HorizontalAlignment.Left;
            scr.VerticalContentAlignment = VerticalAlignment.Top;
            scr.VerticalAlignment = VerticalAlignment.Stretch;
            scr.HorizontalAlignment = HorizontalAlignment.Stretch;
            scr.Content = panel;
            scr.Height = double.NaN;
            scr.Width = double.NaN;
            scr.EndInit();

            return (scr);
        }
Esempio n. 2
0
        public ScrollViewer GetMappedLayerOutputs()
        {
            WrapPanel panel = new WrapPanel();
            panel.BeginInit();
            panel.UseLayoutRounding = true;
            panel.SnapsToDevicePixels = true;
            panel.Orientation = Orientation.Horizontal;
            panel.HorizontalAlignment = HorizontalAlignment.Stretch;
            panel.VerticalAlignment = VerticalAlignment.Stretch;

            for (int map = 0; map < MapCount; ++map)
            {
                Grid grid = new Grid();
                grid.SnapsToDevicePixels = true;
                grid.UseLayoutRounding = true;
                grid.Background = System.Windows.Media.Brushes.White;
                grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                grid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                grid.Width = double.NaN;
                grid.Height = double.NaN;
                grid.Margin = new Thickness(4);

                for (int col = 0; col < MapWidth; col++)
                {
                    ColumnDefinition colDef = new ColumnDefinition();
                    colDef.Width = new GridLength(0, GridUnitType.Auto);
                    grid.ColumnDefinitions.Add(colDef);
                }
                for (int row = 0; row < MapHeight; row++)
                {
                    RowDefinition rowDef = new RowDefinition();
                    rowDef.Height = new GridLength(0, GridUnitType.Auto);
                    grid.RowDefinitions.Add(rowDef);
                }

                grid.BeginInit();

                for (int y = 0; y < MapHeight; y++)
                {
                    for (int x = 0; x < MapWidth; x++)
                    {
                        int index = x + (y * MapWidth) + (map * MapWidth * MapHeight);
                        byte color = (byte)(255 - ((Neurons[index].Output + 1D) * 127D));
                        System.Windows.Media.SolidColorBrush brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(color, color, color));
                        brush.Freeze();
                        System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
                        rectangle.BeginInit();
                        rectangle.SnapsToDevicePixels = true;
                        rectangle.UseLayoutRounding = true;
                        rectangle.HorizontalAlignment = HorizontalAlignment.Stretch;
                        ToolTip tip = new ToolTip();
                        tip.Content = Neurons[index].Output.ToString("N17", CultureInfo.CurrentUICulture);
                        rectangle.ToolTip = tip;
                        rectangle.VerticalAlignment = VerticalAlignment.Stretch;
                        rectangle.Margin = new Thickness(0);
                        rectangle.Height = 8;
                        rectangle.Width = 8;
                        rectangle.Stretch = Stretch.Uniform;
                        rectangle.Fill = brush;
                        rectangle.EndInit();
                        Grid.SetColumn(rectangle, x);
                        Grid.SetRow(rectangle, y);
                        grid.Children.Add(rectangle);
                        brush = null;
                        tip = null;
                        rectangle = null;
                    }
                }
                grid.EndInit();
                panel.Children.Add(grid);
            }
            panel.EndInit();

            ScrollViewer scr = new ScrollViewer();
            scr.BeginInit();
            scr.SnapsToDevicePixels = true;
            scr.UseLayoutRounding = true;
            scr.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
            scr.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            scr.HorizontalContentAlignment = HorizontalAlignment.Left;
            scr.VerticalContentAlignment = VerticalAlignment.Top;
            scr.VerticalAlignment = VerticalAlignment.Stretch;
            scr.HorizontalAlignment = HorizontalAlignment.Stretch;
            scr.Content = panel;
            scr.Height = double.NaN;
            scr.Width = double.NaN;
            scr.EndInit();

            return (scr);
        }