Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Brainnet 1 - A Neural Netwok Project - With Illustration And Code - Learn Neural Network Programming Step By Step And Develop a Simple Handwriting Detection System

, 4 Apr 2007
This article is expected to (1) Demonstrate some practical uses neural network programming (2) Give you a fair idea regarding neurons, neural networks and their applications (3) Introduce BrainNet library - an open source Artificial Neural Network library I developed - mainly using the MS.NET
neuralnetwork_source.zip
BrainNetIntro
BrainNetLibrary
BrainNet.NeuralFramework.dll
Documentation.chm
NeuralGate
bin
BrainNet.NeuralFramework.dll
NeuralGate.exe
NeuralGate.vbproj.user
PatternDetector
bin
BrainNet.NeuralFramework.dll
PatternDetector.exe
TestImages
a1.bmp
b1.bmp
b2.bmp
c1.bmp
c2.bmp
D.bmp
D1.bmp
D2.bmp
E1.bmp
E2.bmp
PatternDetector.vbproj.user
neuralnetwork_src.zip
'Let us import the brainnet framework
Imports BrainNet.NeuralFramework

'<summary> Our simple digital neural gate class </summary>
Public Class DigitalNeuralGate

    'A variable to hold our network
    Private network As BrainNet.NeuralFramework.NeuralNetwork

    '<summary> This is the constructor. Here, we will create a 2-2-1 network </summary>
    Public Sub New()

        'Create the factory to create a Backward Propagation Neural Network
        'Backward Propagation neural network is a commonly used neural network model
        Dim factory As New BrainNet.NeuralFramework.BackPropNetworkFactory()

        'This is an arralist which holds the number of neurons in each layer
        Dim layers As New ArrayList()

        'We need 2 neurons in first layer
        layers.Add(2)
        'We need 2 neurons in the second layer (the second layer is the first
        'hidden layer)
        layers.Add(2)
        'We need one neuron in the output layer
        layers.Add(1)

        'Provide the arraylist as the parameter, to create a network
        network = factory.CreateNetwork(layers)

        'Now, network holds a 2-2-1 neural network object in it.

    End Sub


    '<summary> This is the function for training the network using
    'the brainnet library </summary>
    Public Sub Train(ByVal input1 As Long, ByVal input2 As Long, ByVal output As Long)

        'Create a training data object
        Dim td As New TrainingData()

        'Add inputs to the training data object
        td.Inputs.Add(input1)
        td.Inputs.Add(input2)

        'Add expected output to the training data object
        td.Outputs.Add(output)

        'Train the network one time
        network.TrainNetwork(td)

    End Sub

    '<summary> This is the function for running the network using the
    'brainnet library </summary>
    Public Function Run(ByVal input1 As Long, ByVal input2 As Long) As Double

        'Declare an arraylist to provide as input to the Run method
        Dim inputs As New ArrayList()

        'Add the first input
        inputs.Add(input1)
        'Add the second input
        inputs.Add(input2)

        'Get the output, by calling the network's RunNetwork method
        Dim outputs As ArrayList = network.RunNetwork(inputs)

        'As we have only one neuron in the output layer,
        'let us return its output
        Return outputs(0)

    End Function

    '<summary> This is the function is for saving this gate to 
    'an xml file </summary>
    Public Sub Save(ByVal file As String)
        Dim ser As New BrainNet.NeuralFramework.NetworkSerializer()
        ser.SaveNetwork(file, network)
    End Sub

    '<summary> This is the function is for loading this gate 
    'from an xml file </summary>
    Public Sub Load(ByVal file As String)
        Dim ser As New BrainNet.NeuralFramework.NetworkSerializer()
        ser.LoadNetwork(file, network)
    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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author


| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 4 Apr 2007
Article Copyright 2006 by Anoop Madhusudanan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid