Click here to Skip to main content
15,896,606 members
Articles / Artificial Intelligence / Neural Networks

Multiple convolution neural networks approach for online handwriting recognition

Rate me:
Please Sign up or sign in to vote.
4.95/5 (37 votes)
9 Apr 2013CPOL8 min read 77K   25.1K   74  
The research focuses on the presentation of word recognition technique for an online handwriting recognition system which uses multiple component neural networks (MCNN) as the exchangeable parts of the classifier.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ANN.Perceptron;
using ANN.Perceptron.Common;
using ANN.Perceptron.Network;
using ANN.Perceptron.Layers;
namespace NNControl.NNTraining
{
    public partial class CreateNetworkForm : Form
    {
        ConvolutionNetwork network;
        CommonLayer preLayer;
        List<CommonLayer> layers;
        Size inputPatternSize;
        List<Char> letters;
        bool isUnknownOutput;
        public ConvolutionNetwork Network
        {
            get
            {
                return network;
            }
        }
        public CreateNetworkForm()
        {
            InitializeComponent();
            network = new ConvolutionNetwork();
            layers = null;
            preLayer = null;
            btConvolution.Enabled = false;
            btFullConnected.Enabled = false;
            btOutputLayer.Enabled = false;
            btOk.Enabled = false;
            inputPatternSize = Size.Empty;
            letters = null;
            isUnknownOutput = false;
        }
        private void AddLayerInformationToListView(CommonLayer mLayer)
        {

            String label = mLayer.Label;
            ListViewGroup lvgroup = new ListViewGroup(label);
            lvNetwork.Groups.Add(lvgroup);
            String[] itemTexts = new String[6];
            int neurons = mLayer.NeuronCount;
            itemTexts[0] = neurons.ToString();
            itemTexts[1] = mLayer.FeatureMapSize.ToString();
            itemTexts[2] = mLayer.FeatureMapCount.ToString();
            itemTexts[3] = mLayer.WeightCount.ToString();
            itemTexts[4] = (mLayer.NeuronCount * mLayer.Neurons[0].ConnectionCount).ToString();
            switch (mLayer.LayerType)
            { 
                case LayerTypes.Input:
                    itemTexts[5] = "Input Layer";
                    break;
                case LayerTypes.ConvolutionalSubsampling:
                    itemTexts[5] = "Conv Layer";
                    break;
                case LayerTypes.FullyConnected:
                    itemTexts[5] = "Full Connected Layer";
                    break;
                case LayerTypes.Output:
                    itemTexts[5] = "Output Layer";
                    break;
            }
            ListViewItem item = new ListViewItem(itemTexts);
            lvNetwork.Items.Add(item);
            item.Group = lvgroup;

        }
        private void btInputLayer_Click(object sender, EventArgs e)
        {
            InputLayerForm mform = new InputLayerForm();
            if (mform.ShowDialog() == DialogResult.OK)
            {
                if (mform.Layer != null)
                {
                    if (layers == null)
                    {
                        layers = new List<CommonLayer>();
                    }
                    layers.Add(mform.Layer);
                    inputPatternSize = mform.InputPatternSize;
                    preLayer = mform.Layer;
                    AddLayerInformationToListView(mform.Layer);
                    btConvolution.Enabled = true;
                    btFullConnected.Enabled = true;
                    btOutputLayer.Enabled = true;
                    btInputLayer.Enabled = false;
                }
            }
            
        }

        private void btConvolution_Click(object sender, EventArgs e)
        {
            ConvolutionForm mform = new ConvolutionForm(preLayer);
            if (mform.ShowDialog() == DialogResult.OK)
            {
                if (mform.Layer != null)
                {
                    if (layers != null&&preLayer!=null)
                    {
                        layers.Add(mform.Layer);
                        preLayer = mform.Layer;
                        AddLayerInformationToListView(mform.Layer);
                    }
                
                }
            }
        }

        private void btFullConnected_Click(object sender, EventArgs e)
        {
            FullConnectedForm mform = new FullConnectedForm(preLayer);
            if (mform.ShowDialog() == DialogResult.OK)
            {
                if (mform.Layer != null)
                {
                    if (layers != null && preLayer != null)
                    {
                        layers.Add(mform.Layer);
                        preLayer = mform.Layer;
                        AddLayerInformationToListView(mform.Layer);
                    }

                }
            }
        }

        private void btOutputLayer_Click(object sender, EventArgs e)
        {
            OutputLayerForm mform = new OutputLayerForm(preLayer);
            if (mform.ShowDialog() == DialogResult.OK)
            {
                if (mform.Layer != null)
                {
                    if (layers != null && preLayer != null)
                    {
                        letters = mform.OutputLetters;
                        isUnknownOutput = mform.IsUnknownOutput;
                        layers.Add(mform.Layer);
                        preLayer = mform.Layer;
                        AddLayerInformationToListView(mform.Layer);
                        btConvolution.Enabled = false;
                        btFullConnected.Enabled = false;
                        btOutputLayer.Enabled = false;
                        btInputLayer.Enabled = false;
                        btOk.Enabled = true;
                    }

                }
            }
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            if (letters.Count > 0)
            {
                network.Layers = layers.ToArray();
                network.LayerCount = layers.Count;
                network.InputDesignedPatternSize = inputPatternSize;
                network.TagetOutputs = letters;
                network.IsUnknownOutput = isUnknownOutput;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Vietnam Maritime University
Vietnam Vietnam
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions