Пример #1
0
        static void MNISTLeakyReLUSigmoidAdamAndMeanSquaredError()
        {
            ConsoleUI.WriteLine("LeakyReLU, Sigmoid - MSE, Adam");

            var(XTrain, yTrain) = MNISTHelper.LoadTraining(0, 1);
            var(XTest, yTest)   = MNISTHelper.LoadTesting(0, 1);

            var model = new Model(new AdamOptimiser(learningRate: 2e-3, beta1: 0.5), new MeanSquaredErrorCost());

            model.Add(new DenseLayer(28 * 28, 100, new LeakyReLUActivation(0.05)));
            model.Add(new DenseLayer(100, 10, new SigmoidActivation()));

            MNISTTest(model, XTrain, yTrain, XTest, yTest, 1);
        }
Пример #2
0
        static void MNISTLTanHSigmoidSDGAndMeanSquareError()
        {
            ConsoleUI.WriteLine("TanH, Sigmoid - MSE, SGD");

            var(XTrain, yTrain) = MNISTHelper.LoadTraining(-1, 1);
            var(XTest, yTest)   = MNISTHelper.LoadTesting(-1, 1);

            var model = new Model(new SGDOptimiser(learningRate: 0.1), new MeanSquaredErrorCost());

            model.Add(new DenseLayer(28 * 28, 100, new TanhActivation()));
            model.Add(new DenseLayer(100, 10, new SigmoidActivation()));

            MNISTTest(model, XTrain, yTrain, XTest, yTest, 1);
        }
Пример #3
0
        private static void SimpleGAN()
        {
            string imageFolder = CreateImageFolder();

            ConsoleUI.WriteLine("Enter a comma separated list of numbers from 0 to 9 to train the GAN on those digits.");
            ConsoleUI.WriteLine("Just press enter to train the GAN on all digits (this will take a *long* time).");
            ConsoleUI.WriteLine($"Example generated images will be written into '{imageFolder}' at the end of each epoch.");

            var(XTrain, _) = MNISTHelper.LoadTraining(scaleMin: -1, scaleMax: 1, filter: GetFilterFromUser());

            var adam          = new AdamOptimiser(learningRate: 2e-4, beta1: 0.5, beta2: 0.999);
            var generator     = BuildGenerator(adam);
            var discriminator = BuildDiscriminator(adam);

            Train(imageFolder, XTrain, generator, discriminator);
        }