コード例 #1
0
        public void CreateAndCompileModel3()
        {
            Console.WriteLine("Creating model");
            GlobalRandom.InitializeRandom();

            int imgSize = 75;

            ReluActivation    reluActivation    = new ReluActivation();
            SoftmaxActivation softmaxActivation = new SoftmaxActivation();

            model = new ConvolutionalNeuralNetwork(imgSize, "rgb");
            model.Add(new ConvolutionalLayer(5, 5, reluActivation, "valid"));
            model.Add(new MaxPoolingLayer());
            model.Add(new ConvolutionalLayer(5, 3, reluActivation, "valid"));
            model.Add(new MaxPoolingLayer());
            model.Add(new DropoutLayer(0.2));
            model.Add(new FlattenLayer());
            model.Add(new DropoutLayer(0.5));
            model.Add(new DenseLayer(26, softmaxActivation));

            Console.WriteLine("Model created");

            model.Compile();

            Console.WriteLine("Model compiled");
        }
コード例 #2
0
        public MnistCNNGUI()
        {
            InitializeComponent();

            string trainImgPath = "res/train-images.idx3-ubyte"
            , trainLblPath      = "res/train-labels.idx1-ubyte"
            , testImgPath       = "res/t10k-images.idx3-ubyte"
            , testLblPath       = "res/t10k-labels.idx1-ubyte";

            trainingImages = MnistImage.ProcessMNISTFile(trainImgPath, trainLblPath);
            testImages     = MnistImage.ProcessMNISTFile(testImgPath, testLblPath);

            mnistNetwork = new ConvolutionalNeuralNetwork(new ConvolutionalNeuralNetworkProps(28, 28, 90, 10, 6, 5, 5, 2, 2));
            mnistNetwork.UploadTrainingSet(trainingImages);
            mnistNetwork.UploadTestSet(testImages);
            mnistNetwork.NumEpochs = 1;

            //mnistNetwork.TestTrainingSet();
            mnistNetwork.Test(true);
            UpdateSensitivity();

            selectedImageSet = testImages;

            LoadImage(0);
            UseTrainingSetCheckBox_CheckedChanged(null, null);

            NetworkWorker = new BackgroundWorker();
            NetworkWorker.WorkerReportsProgress = true;
            NetworkWorker.DoWork          += TrainNetwork;
            NetworkWorker.ProgressChanged += (object sender, ProgressChangedEventArgs e) =>
            {
                int percent = e.ProgressPercentage;
                TrainingProgressLabel.Text = $"Network Progress: {percent}%";
                TrainingProgressBar.Value  = percent;
            };
            NetworkWorker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
            {
                UpdateSensitivity();
                SetNetworkActive(true);
                TrainingProgressLabel.Text = e.Cancelled == false ? $"Network Progress: {0}% (finished)" : "Network Progress: {0}% (cancelled)";
                TrainingProgressBar.Value  = 0;
                TotalEpochLabel.Text       = $"Total Trained Epochs: {mnistNetwork.TotalEpochs.ToString("n2")}";
                TestImage();
            };
            NetworkWorker.WorkerSupportsCancellation = true;

            NumEpochsComboBox.SelectedIndex = 0;
        }
コード例 #3
0
        public void CreateAndCompileModel(string jsonPath, string weightsDirectory)
        {
            Console.WriteLine("Creating model");
            GlobalRandom.InitializeRandom();

            model = new ConvolutionalNeuralNetwork(jsonPath);

            Console.WriteLine("Model created");

            model.Compile();

            Console.WriteLine("Model compiled");
            Console.WriteLine("Reading weights");
            //ReadWeightsFromDirectory(weightsDirectory);

            ReadWeightsFromDirectory(weightsDirectory);
        }
コード例 #4
0
        public void CreateAndCompileModelMnist()
        {
            Console.WriteLine("Creating model");
            GlobalRandom.InitializeRandom();

            int imgSize = 28;

            NoActivation      noActivation      = new NoActivation();
            SoftmaxActivation softmaxActivation = new SoftmaxActivation();

            model = new ConvolutionalNeuralNetwork(imgSize, "grayscale");
            model.Add(new ConvolutionalLayer(8, 3, noActivation, "valid"));
            model.Add(new MaxPoolingLayer());
            model.Add(new FlattenLayer());
            model.Add(new DenseLayer(10, softmaxActivation));

            Console.WriteLine("Model created");

            model.Compile();

            Console.WriteLine("Model compiled");
        }
コード例 #5
0
ファイル: Trainer.cs プロジェクト: Coestaris/mllib
 public Trainer(ConvolutionalNeuralNetwork network, double learningRate)
 {
     LearningRate = learningRate;
     _network     = network;
 }