Example #1
0
        public void TestRandomNormalInitialization()
        {
            var initialization = Initializations.RandomNormal();

            initialization.SetSeed(0);

            var initializedMatrix = initialization.Initialize(2, 2);

            var expectedMatrix = Matrix <double> .Build.Random(2, 2, new Normal(new Random(0)));

            Console.WriteLine(initializedMatrix);
            Console.WriteLine(expectedMatrix);

            Assert.AreEqual(initializedMatrix, expectedMatrix);
        }
Example #2
0
        static void Main(string[] args)
        {
            var X = Matrix <double> .Build.Random(5, 100);

            var Y = Matrix <double> .Build.Random(1, 100);

            var test = Matrix <double> .Build.Random(5, 1);


            var model = new DeepCat();

            model.Add(new Dense(5, Activations.Relu(), weightInitializer: Initializations.RandomNormal()));
            model.Add(new Dense(5, Activations.Relu(), weightInitializer: Initializations.RandomNormal()));
            model.Add(new Dense(1, Activations.Sigmoid()));

            model.Compile(X.RowCount, LossFunctions.CrossEntropy(), Optimizers.GradientDescent(0.002));

            model.Fit(X, Y, 100);
            model.Predict(test);



            var x = 1;
        }