Exemplo n.º 1
0
    public static Pixbuf Get(ManagedCNN cnn, int layer, int i, int j)
    {
        if (layer >= 0 && layer < cnn.Layers.Count && cnn.Layers[layer].Type == LayerTypes.Convolution && i >= 0 && i < cnn.Layers[layer].FeatureMap.i && j >= 0 && j < cnn.Layers[layer].FeatureMap.j)
        {
            var FeatureMap = new ManagedArray(cnn.Layers[layer].FeatureMap.x, cnn.Layers[layer].FeatureMap.y, cnn.Layers[layer].FeatureMap.z);
            var Transposed = new ManagedArray(FeatureMap);
            var pixbuf     = new Pixbuf(Colorspace.Rgb, false, 8, FeatureMap.y, FeatureMap.x);

            ManagedOps.Copy4DIJ2D(FeatureMap, cnn.Layers[layer].FeatureMap, i, j);
            ManagedMatrix.Transpose(Transposed, FeatureMap);

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

            FullyConnected.GetNormalization(Transposed, ref min, ref max);

            Activation.Draw(pixbuf, Transposed, min, max);

            ManagedOps.Free(Transposed);

            return(pixbuf);
        }

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

                ManagedOps.Copy4DIJ2D(FeatureMap, cnn.Layers[layer].FeatureMap, i, j);
                ManagedMatrix.Transpose(Transposed, FeatureMap);

                // 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(FeatureMap, Transposed);

                return(bitmap);
            }

            // return empty bitmap
            return(new Bitmap(1, 1, PixelFormat.Format24bppRgb));
        }