示例#1
0
        public override Volume <double> Random(Shape shape, double mu = 0, double std = 1.0)
        {
            var vol = new Volume(new NcwhVolumeStorage <double>(shape));

            for (var n = 0; n < shape.Dimensions[3]; n++)
            {
                for (var c = 0; c < shape.Dimensions[2]; c++)
                {
                    for (var y = 0; y < shape.Dimensions[1]; y++)
                    {
                        for (var x = 0; x < shape.Dimensions[0]; x++)
                        {
                            vol.Set(x, y, c, n, RandomUtilities.Randn(mu, std));
                        }
                    }
                }
            }

            return(vol);
        }
示例#2
0
        public override Volume <double> Random(Shape shape, double mu = 0, double std = 1.0)
        {
            //RandomUtilities.RandomDoubleArray(shape.TotalLength, mu, std), shape)
            var vol = new Volume(new NcwhVolumeStorage <double>(shape));

            for (int n = 0; n < shape.GetDimension(3); n++)
            {
                for (int c = 0; c < shape.GetDimension(2); c++)
                {
                    for (int y = 0; y < shape.GetDimension(1); y++)
                    {
                        for (int x = 0; x < shape.GetDimension(0); x++)
                        {
                            vol.Set(x, y, c, n, RandomUtilities.Randn(mu, std));
                        }
                    }
                }
            }

            return(vol);
        }
示例#3
0
            /// <summary>
            ///     Volume will be filled with random numbers
            /// </summary>
            /// <param name="width">width</param>
            /// <param name="height">height</param>
            /// <param name="depth">depth</param>
            public Volume(int width, int height, int depth)
            {
                // we were given dimensions of the vol
                this.Width  = width;
                this.Height = height;
                this.Depth  = depth;

                var n = width * height * depth;

                this.Weights         = new double[n];
                this.WeightGradients = new double[n];

                // weight normalization is done to equalize the output
                // variance of every neuron, otherwise neurons with a lot
                // of incoming connections have outputs of larger variance
                var scale = Math.Sqrt(1.0 / (width * height * depth));

                for (var i = 0; i < n; i++)
                {
                    this.Weights[i] = RandomUtilities.Randn(0.0, scale);
                }
            }