0

I am trying to recognize 0 to 9 digits using Aforge.net . I tried everything but I am still unable to get result please look at my program and why I am unable to recognize digits. Problem may be in number of hidden layers, learning rate or input data , I have tried it by changing number of hidden layers and learning rate. Please suggest ideas.

// opening file
OpenFileDialog open = new OpenFileDialog();
ActivationNetwork enactivation = new ActivationNetwork(new BipolarSigmoidFunction(1),  3886,10, 10);
double[][] input = new double[10][];
double[][] output = new double[10][];
//generating input data using Feature class -- which code is given below

Feature feature = new Feature();

//iterating for all 10 digits. 
for (int i = 0; i < 10; i++)
        {
           open.ShowDialog();
           Bitmap bitmap = new Bitmap(open.FileName);
          double[] features = feature.features(bitmap);
            input[i] = features;
             features = feature.features(bitmap);
            output[i] = feature.features(bitmap);
         }

enactivation.Randomize();
        BackPropagationLearning learn = new BackPropagationLearning(enactivation);
//learning 
        learn.LearningRate = 0.005f;
        learn.Momentum = 0.005f;
        double errora;
        int iteration = 0;

        while (true)
        {
            errora = learn.RunEpoch(input, output);
            if (errora < 0.0006)
                break;
            else if (iteration > 23000)
               break;
            iteration++;
           // Console.WriteLine("error {0} {1} ", errora, iteration);
       }
       double[] sample;
        open.ShowDialog();
        Bitmap temp = new Bitmap(open.FileName);
       // providing input for computation using feature class
        sample = feature.features(temp);
        foreach (double daa in enactivation.Compute(sample))
        {
            Console.WriteLine(daa);
        }

Class Feature for providing input for training nural network class Feature {

    public double[] features(Bitmap bitmap)
    {
        //feature 
        double[] feature = new double[bitmap.Width * bitmap.Height];
       int featurec = 0;
        for (int vert = 0; vert < bitmap.Height; vert++)
        {
            for (int horizantal = 0; horizantal < bitmap.Width; horizantal++)
            {
                feature[featurec] = bitmap.GetPixel(horizantal, vert).ToArgb();
                if (feature[featurec] < 1)
                {
                    feature[featurec] = -0.5;
                }
                else
                {
                    feature[featurec] = 0.5;
                }
                featurec++;
            }
        }
        return feature;
    }

}

user3292157
  • 13
  • 2
  • 4
  • I suggest you take a look at [Accord.NET](http://accord-framework.net/) which is practically an extension of AForge.NET Framework. In the [Samples Gallery](http://accord-framework.net/samples.html) you will also find a number of handwriting character recognition applications and similar. – Anders Gustafsson Jun 07 '14 at 15:37

1 Answers1

0

I haven't used aforge, but re. using backprop neural nets for this problem:

  1. You need something like a 10x10 input grid with each cell in the grid getting 1/100 of the image

  2. You need at least one, possibly 2, hidden layers

  3. The net will train faster with a bias input - meaning a source of a fixed value - for each cell (this lets the cells train faster: Role of Bias in Neural Networks)

  4. I'd never start in bp mode but always run something a statistical annealing first. Bp is for descending inside a local minimum once one is found

Also:

  • Have you successfully used aforge for other problems?

  • What happens when you try to train the net?

Community
  • 1
  • 1
user15677
  • 41
  • 2
  • Hello , Thanks for answer . Yes I have used for computer vision . I used nural network 1st time, when I train input and output data and later try to recognize any character it gives false answer . Suppose I fed it 1 and it recognize it 8 . Can you test above code and please let me know where is problem. – user3292157 Jun 08 '14 at 06:07