Exemplo n.º 1
0
        public static Bitmap Get(ManagedCNN cnn, int layer, int map)
        {
            if (layer >= 0 && layer < cnn.Layers.Count && map >= 0 && map < cnn.Layers[layer].Activation.i)
            {
                var Activation = new ManagedArray(cnn.Layers[layer].Activation.x, cnn.Layers[layer].Activation.y, cnn.Layers[layer].Activation.z);
                var Transposed = new ManagedArray(Activation);
                var bitmap     = new Bitmap(cnn.Layers[layer].Activation.x, cnn.Layers[layer].Activation.y, PixelFormat.Format24bppRgb);

                ManagedOps.Copy4D2D(Activation, cnn.Layers[layer].Activation, 0, map);
                ManagedMatrix.Transpose(Transposed, Activation);

                // Get normalization values
                double min = Double.MaxValue;
                double max = Double.MinValue;

                for (int y = 0; y < Transposed.y; y++)
                {
                    for (int x = 0; x < Transposed.x; x++)
                    {
                        if (Transposed[x, y] > max)
                        {
                            max = Transposed[x, y];
                        }

                        if (Transposed[x, y] < min)
                        {
                            min = Transposed[x, y];
                        }
                    }
                }

                Draw(bitmap, Transposed, min, max);

                ManagedOps.Free(Activation, Transposed);

                return(bitmap);
            }

            // return empty bitmap
            return(new Bitmap(1, 1, PixelFormat.Format24bppRgb));
        }
Exemplo n.º 2
0
    public static Pixbuf Get(ManagedCNN cnn, int layer, int map)
    {
        if (layer >= 0 && layer < cnn.Layers.Count && map >= 0 && map < cnn.Layers[layer].Activation.i)
        {
            var Activation = new ManagedArray(cnn.Layers[layer].Activation.x, cnn.Layers[layer].Activation.y, cnn.Layers[layer].Activation.z);
            var Transposed = new ManagedArray(Activation);
            var pixbuf     = new Pixbuf(Colorspace.Rgb, false, 8, Activation.y, Activation.x);

            ManagedOps.Copy4D2D(Activation, cnn.Layers[layer].Activation, 0, map);
            ManagedMatrix.Transpose(Transposed, Activation);

            // Get normalization values
            double min = Double.MaxValue;
            double max = double.MinValue;

            for (int y = 0; y < Transposed.y; y++)
            {
                for (int x = 0; x < Transposed.x; x++)
                {
                    if (Transposed[x, y] > max)
                    {
                        max = Transposed[x, y];
                    }

                    if (Transposed[x, y] < min)
                    {
                        min = Transposed[x, y];
                    }
                }
            }

            Draw(pixbuf, Transposed, min, max);

            ManagedOps.Free(Activation, Transposed);

            return(pixbuf);
        }

        // return empty pixbuf
        return(new Pixbuf(Colorspace.Rgb, false, 8, 1, 1));
    }