示例#1
0
 static Matrix feedForwardAlgirithm(String[] words)
 {
     try
     {
         if (words.Length == 1)
         {
             Console.WriteLine("Feed Forward must have some parameters!");
             return(null);
         }
         float[] input = new float[words.Length - 1];
         for (int i = 0; i < words.Length - 1; i++)
         {
             input[i] = float.Parse(words[i + 1]);
         }
         if (nn == null)
         {
             Console.WriteLine("You must first initialize a Neural Network");
             return(null);
         }
         return(nn.feedforward(input));
     } catch (Exception e)
     {
         Console.WriteLine("Feed Forward Failed!");
         printError(e);
         return(null);
     }
 }
示例#2
0
        static void Train(String[] words)
        {
            Layer[] layer = new Layer[]
            {
                new ConvolutionalLayer(3, 3, 3, 0, 1),
                new ConvolutionalLayer(3, 3, 3, 0, 1),              //26
                new Lib.Layers.Convolutional.LeakyReluLayer(),
                new ConvolutionalLayer(2, 2, 3, 0, 1),              //24
                new Lib.Layers.Convolutional.LeakyReluLayer(),
                new ConvolutionalLayer(2, 2, 3, 0, 1),              //22
                new Lib.Layers.Convolutional.LeakyReluLayer(),
                new FullyConnectedLayer(1728),
                new SoftmaxLayer(10)
            };

            nn = new Lib.NeuralNetwork(Lib.NeuralNetwork.random, layer);

            if (nn == null)
            {
                Console.WriteLine("you must first initialize a Neural Network.");
                return;
            }

            TrainingData[] data    = Loader.loadTestMNSIT(@"C:\Users\drumm\Desktop\MNIST");
            Trainer        trainer = new Trainer(data);

            Matrix.table(nn.feedforward(data[0].inputs));

            Matrix.table(data[0].labels);


            trainer.Train(nn);

            Matrix.table(data[0].labels);


            Matrix.table(nn.feedforward(data[0].inputs));
            Console.WriteLine("Training is completed succesfully!");
        }