コード例 #1
0
ファイル: Program.cs プロジェクト: jiajunhua/Microsoft-CNTK
        static void Main(string[] args)
        {
            var device = DeviceDescriptor.CPUDevice;

            Console.WriteLine($"======== running LogisticRegression.TrainAndEvaluate using {device.Type} ========");
            LogisticRegression.TrainAndEvaluate(device);

            Console.WriteLine($"======== running MNISTClassifier.TrainAndEvaluate with multilayer perceptron (MLP) classifier using {device.Type} ========");
            MNISTClassifier.TrainAndEvaluate(device, false, true);

            Console.WriteLine($"======== running MNISTClassifier.TrainAndEvaluate with convolutional neural network using {device.Type} ========");
            MNISTClassifier.TrainAndEvaluate(device, true, true);

            // Batch normalization is not available on CPU build. See following examples in GPU project.
            // Following examples will be enabled once BN is supported on CPU.
            //Console.WriteLine("======== running CifarResNet.TrainAndEvaluate using CPU ========");
            //CifarResNetClassifier.TrainAndEvaluate(device, true);

            //Console.WriteLine("======== running TransferLearning.TrainAndEvaluateWithFlowerData using CPU ========");
            //TransferLearning.TrainAndEvaluateWithFlowerData(device, true);

            //Console.WriteLine("======== running TransferLearning.TrainAndEvaluateWithAnimalData using CPU ========");
            //TransferLearning.TrainAndEvaluateWithAnimalData(device, true);

            Console.WriteLine($"======== running LSTMSequenceClassifier.Train using {device.Type} ========");
            LSTMSequenceClassifier.Train(device);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var device = DeviceDescriptor.GPUDevice(0);

            Console.WriteLine($"======== running LogisticRegression.TrainAndEvaluate using {device.Type} ========");
            LogisticRegression.TrainAndEvaluate(device);

            Console.WriteLine($"======== running MNISTClassifier.TrainAndEvaluate with multilayer perceptron (MLP) classifier using {device.Type} ========");
            MNISTClassifier.TrainAndEvaluate(device, false, true);

            Console.WriteLine($"======== running MNISTClassifier.TrainAndEvaluate with convolutional neural network using {device.Type} ========");
            MNISTClassifier.TrainAndEvaluate(device, true, true);

            Console.WriteLine($"======== running CifarResNet.TrainAndEvaluate using {device.Type} ========");
            CifarResNetClassifier.TrainAndEvaluate(device, true);

            Console.WriteLine($"======== running TransferLearning.TrainAndEvaluateWithFlowerData using {device.Type} ========");
            TransferLearning.TrainAndEvaluateWithFlowerData(device, true);

            Console.WriteLine($"======== running TransferLearning.TrainAndEvaluateWithAnimalData using {device.Type} ========");
            TransferLearning.TrainAndEvaluateWithAnimalData(device, true);

            Console.WriteLine($"======== running LSTMSequenceClassifier.Train using {device.Type} ========");
            LSTMSequenceClassifier.Train(device);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var device = DeviceDescriptor.GPUDevice(0);

            Console.WriteLine($"======== runing MNISTClassifierTest.TrainAndEvaluate using {device.Type} with logistic classifier ========");
            MNISTClassifier.TrainAndEvaluate(device, false, true);

            Console.WriteLine($"======== runing MNISTClassifierTest.TrainAndEvaluate using {device.Type} with convolution classifier ========");
            MNISTClassifier.TrainAndEvaluate(device, true, true);

            Console.WriteLine($"======== runing CifarResNet.TrainAndEvaluate using {device.Type} ========");
            CifarResNetClassifier.TrainAndEvaluate(device, true);

            Console.WriteLine($"======== runing TransferLearning.TrainAndEvaluateWithFlowerData using {device.Type} ========");
            TransferLearning.TrainAndEvaluateWithFlowerData(device, true);

            Console.WriteLine($"======== runing TransferLearning.TrainAndEvaluateWithAnimalData using {device.Type} ========");
            TransferLearning.TrainAndEvaluateWithAnimalData(device, true);

            Console.WriteLine($"======== runing LSTMSequenceClassifier.Train using {device.Type} ========");
            LSTMSequenceClassifier.Train(device, true);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var device = DeviceDescriptor.CPUDevice;

            Console.WriteLine($"======== runing MNISTClassifierTest.TrainAndEvaluate using {device.Type} with logistic classifier ========");
            MNISTClassifier.TrainAndEvaluate(device, false, true);

            Console.WriteLine($"======== runing MNISTClassifierTest.TrainAndEvaluate using {device.Type} with convolution classifier ========");
            MNISTClassifier.TrainAndEvaluate(device, true, true);

            // batch normalization is not available on CPU build. These examples are in the GPU project.
            //Console.WriteLine("======== runing CifarResNet.TrainAndEvaluate using CPU ========");
            //CifarResNetClassifier.TrainAndEvaluate(device, true);

            //Console.WriteLine("======== runing TransferLearning.TrainAndEvaluateWithFlowerData using CPU ========");
            //TransferLearning.TrainAndEvaluateWithFlowerData(device, true);

            //Console.WriteLine("======== runing TransferLearning.TrainAndEvaluateWithAnimalData using CPU ========");
            //TransferLearning.TrainAndEvaluateWithAnimalData(device, true);

            Console.WriteLine($"======== runing LSTMSequenceClassifier.Train using {device.Type} ========");
            LSTMSequenceClassifier.Train(device, true);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            TestCommon.TestDataDirPrefix = "../../";
            var device = DeviceDescriptor.GPUDevice(0);

            Console.WriteLine($"======== running LogisticRegression.TrainAndEvaluate using {device.Type} ========");
            LogisticRegression.TrainAndEvaluate(device);

            Console.WriteLine($"======== running MNISTClassifier.TrainAndEvaluate with multilayer perceptron (MLP) classifier using {device.Type} ========");
            MNISTClassifier.TrainAndEvaluate(device, false, true);

            Console.WriteLine($"======== running MNISTClassifier.TrainAndEvaluate with convolutional neural network using {device.Type} ========");
            MNISTClassifier.TrainAndEvaluate(device, true, true);

            Console.WriteLine($"======== running CifarResNet.TrainAndEvaluate using {device.Type} ========");
            CifarResNetClassifier.CifarDataFolder = "../../Examples/Image/DataSets/CIFAR-10";
            CifarResNetClassifier.TrainAndEvaluate(device, true);
            TestCommon.TestDataDirPrefix = "../../Examples/Image/DataSets/";
            string modelFileSourceDir = "../../PretrainedModels/ResNet_18.model";

            if (!File.Exists(modelFileSourceDir))
            {
                Console.WriteLine("Model file doesn't exist. Please run download_model.py in CNTK/CNTK/PretrainedModels");
                Console.ReadKey();
                return;
            }

            TransferLearning.BaseResnetModelFile = "ResNet_18.model";
            File.Copy(modelFileSourceDir, TransferLearning.ExampleImageFolder + TransferLearning.BaseResnetModelFile, /*overwrite*/ true);
            Console.WriteLine($"======== running TransferLearning.TrainAndEvaluateWithAnimalData using {device.Type} ========");
            TransferLearning.TrainAndEvaluateWithAnimalData(device, true);

            TestCommon.TestDataDirPrefix = "../../";
            Console.WriteLine($"======== running LSTMSequenceClassifier.Train using {device.Type} ========");
            LSTMSequenceClassifier.Train(device);
        }