Ejemplo n.º 1
0
        public void cntk_random_uniform()
        {
            using (var K = new CNTKBackend())
            {
                #region doc_random_uniform
                var kvar = K.random_uniform(new int?[] { 100, 2000 }, minval: -4, maxval: 2, dtype: DataType.Double, seed: 1337, name: "uni");
                var a    = K.dtype(kvar); // float64 (Double)
                var b    = kvar.eval();
                #endregion

                double[,] actual = (double[, ])b;
                Assert.AreEqual(100, actual.Rows());
                Assert.AreEqual(2000, actual.Columns());

                var u = UniformContinuousDistribution.Estimate(actual.Reshape());
                Assert.AreEqual(-4, u.Minimum, 1e-3);
                Assert.AreEqual(+2, u.Maximum, 1e-3);
                Assert.AreEqual(-1, u.Mean, 1e-2);
            }
        }