- brainnet_src.zip
- BrainNet.sln
- BrainNet.suo
- BrainNetIntro
- NeuralGate
- PatternDetector
- Doc
- Documentation.chm
- Framework
- nxml
- Samples
- HandWriting
|
'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.
Architect, Developer, Speaker | Wannabe GUT inventor & Data Scientist | Microsoft MVP in C#