Home > Class & module > 3.Collection > NeuralNet

NeuralNet

 

This class includes artificial neural network prediction modules.

A user can use maximum 5 instances of NeuralNet including 'NeuralNet', 'NeuralNet2', 'NeuralNet3', 'NeuralNet4', and 'NeuralNet5'. 

 


o Summary

 Module

 Description

 Sub OpenNN_Once (Source_FileName As String)

 Open trained neural network data file once

 Sub PredictNN ()

 Perform prediction

 Property InputCount () As Integer

 Get total number of input variables

 Property InputData (InputNumber As Integer) As Single

 Set value to input variable

 Property OutputCount() As Integer

 Get total number of output variables

 Property OutputData (OutputNumber As Integer) As Single

 Read predicted value of output variable

 


o Example 1

Open trained network and then predict result

Function Main()

    Call NeuralNet.OpenNN_Once("Sample SinCos - Trained network.vgn")

    NeuralNet.InputData(1)=0.37146

    NeuralNet.InputData(2)=0.88627

    NeuralNet.InputData(3)=0.41384

    Call NeuralNet.PredictNN()

    Output2=NeuralNet.OutputData(2)

    Main=Output2

End Function

 

o Example 2

This is sample included in the Visual Gene Developer. Reconstruct 2D color image using trained neural network

Function Main()

 

   '---- Parameters -------------------

   ResolutionSize=5

   ViewPortSize=350

 

 

   '---- Define Canvas ------------------------

   Call CustomUI.Define_Canvas(ViewPortSize,ViewPortSize)

   Call CustomUI.Clear_Canvas

   CustomUI.Form_BringToFront

   CustomUI.Form_Caption="2D color mapping using artificial neural network"

 

 

   '--- Load trained neural network map ---------------

   Call NeuralNet.OpenNN_Once("Sample 2DColorMap - Trained network.vgn")

 

 

   '---- Draw 2D map ----------------------------------------------

  For y= 0 to ViewPortSize step ResolutionSize

     For x=0 to ViewPortSize step ResolutionSize

 

         'Assign inputs

         NeuralNet.InputData(1)=x/ViewPortSize

         NeuralNet.InputData(2)=y/ViewPortSize

 

         'Predict

         Call NeuralNet.PredictNN()

 

         'Read outputs

         Red=NeuralNet.OutputData(1)*255

         Green=NeuralNet.OutputData(2)*255

         Blue=NeuralNet.OutputData(3)*255

 

        'Set fill color and draw rectangle

        Call CustomUI.Set_FillColor_byRGB(Red,Green,Blue)

        Call CustomUI.FillRectangle(x,y,ResolutionSize,ResolutionSize)

     Next

 Next   

 

   '--- Finalize CustomUI -----------------

   CustomUI.Make_Clone

 

End Function