Click here to Skip to main content
12,626,813 members (33,592 online)
Click here to Skip to main content

Stats

264K views
7K downloads
355 bookmarked
Posted

Designing And Implementing A Neural Network Library For Handwriting Detection, Image Analysis etc.- The BrainNet Library - Full Code, Simplified Theory, Full Illustration, And Examples

, 21 Oct 2009 CPOL
This article will explain the actual concepts and implementation of Backward Propagation Neural Networks very easily - see project code and samples, like a simple pattern detector, a hand writing detection pad, an xml based neural network processing language etc in the source zip.
BrainNetIntro
NeuralGate
NeuralGate.vbproj.user
PatternDetector
PatternDetector.vbproj.user
TestImages
a1.bmp
b1.bmp
b2.bmp
c1.bmp
c2.bmp
D.bmp
D1.bmp
D2.bmp
E1.bmp
E2.bmp
Thumbs.db
Framework
BrainNet.suo
NetworkDataModel
Network.xsx
NeuralXML.xsx
NetworkIO.xsx
NeuralFramework.vbproj.user
nxml
nxml.vbproj.user
BrainNet.suo
Doc
Documentation.chm
Samples
HandWriting
HandWriting.suo
HandWriting.vbproj.user
'------------------------------------------------------------------
' License Notice:
'------------------------------------------------------------------
' All Rights Reserved - Anoop Madhusudanan, 
' Mail: amazedsaint@gmail.com
' Website: http://amazedsaint.blogspot.com

' See my articles about BrainNet at 
' http://amazedsaint-articles.blogspot.com for details
'
' You can use this code (or part of it), for non 
' commercial and academic uses, as long as 
'   - You are keeping this notice along with it
'   - You are not making any profit out of this
'------------------------------------------------------------------

Imports System.Math

'''<summary> Exception that may be thrown by NeuronStrategy class </summary>
Public Class NeuronStrategyException
    Inherits NeuralFrameworkException

    Sub New(ByVal Message As String, ByVal e As Exception)
        MyBase.New(Message, e)
    End Sub


End Class


'''<summary> A backward propagation neuron strategy. This is a concrete implementation of INeuronStrategy </summary>
Public Class BackPropNeuronStrategy
    Implements INeuronStrategy

    '''Major Methods


    '''<summary> Implementation of Find Delta </summary>
    Public Overridable Function FindDelta(ByVal output As Single, ByVal errorFactor As Single) As Single Implements NeuralFramework.INeuronStrategy.FindDelta
        Try
            Return output * (1 - output) * errorFactor
        Catch e As Exception
            Throw New NeuronStrategyException("Exception in Finding Delta", e)
        End Try
    End Function

    '''<summary> Implementation of activation function </summary>
    Public Overridable Function Activation(ByVal value As Single) As Single Implements NeuralFramework.INeuronStrategy.Activation
        Try
            Return (1 / (1 + Exp(value * -1)))
        Catch e As Exception
            Throw New NeuronStrategyException("Exception in Activation function", e)
        End Try

    End Function


    '''<summary> Implementation of finding net value </summary>
    Public Overridable Function FindNetValue(ByVal Inputs As NeuronConnections, ByVal bias As Single) As Single Implements NeuralFramework.INeuronStrategy.FindNetValue
        Try
            Dim nur As INeuron
            Dim sum As Single = bias

            For Each nur In Inputs.Neurons
                sum = sum + (Inputs.Weight(nur) * nur.OutputValue)
            Next
            Return sum
        Catch e As Exception
            Throw New NeuronStrategyException("Exception in Finding Net Value", e)
        End Try



    End Function

    '''<summary> Implementation of Finding new bias value</summary>
    Public Function FindNewBias(ByVal bias As Single, ByVal delta As Single) As Single Implements BrainNet.NeuralFramework.INeuronStrategy.FindNewBias
        Try
            Return bias + LEARNING_RATE * 1 * delta

        Catch e As Exception
            Throw New NeuronStrategyException("Exception in Finding New Bias Value", e)
        End Try
    End Function

    '''<summary> Calculating the new weight values</summary>
    Public Sub UpdateWeights(ByRef connections As NeuronConnections, ByVal delta As Single) Implements BrainNet.NeuralFramework.INeuronStrategy.UpdateWeights

        Try
            Dim nur As INeuron
            For Each nur In connections.Neurons
                '''InputNeuron'''s weights = inp neurons'''s Weight + LEARNING_RATE * InputNeuron'''s.Output * Delta
                connections.Weight(nur) = connections.Weight(nur) + LEARNING_RATE * nur.OutputValue * delta
            Next

        Catch e As Exception
            Throw New NeuronStrategyException("Exception while updating the weight values", e)
        End Try

    End Sub
End Class



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)

Share

About the Author


You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161205.3 | Last Updated 21 Oct 2009
Article Copyright 2006 by Anoop Madhusudanan
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid