| California Scientific BrainMaker Neural Network Software | ||||||
| Home | Applications | What Are Neural Networks | Products | Ordering Info | Tech Support | |
Using Runtime.DLL with Visual BasicBrainMaker Pro comes with runtime.dll, which you use to run a trained network from your own program. Your program can be in C or Visual Basic. Visual Basic requires routines in DLLs to use the __stdcall calling convention, while C-callable routines use the __cdecl calling convention. The runtime dll has two sets of exported routines: one set for use from C and the other for use from Visual Basic. The Visual Basic routines have the same names but prepended with the prefix "std" and using the __stdcall convention. Following is an example of VB declaration code: Declare Function InitializeNetwork _ Lib "Runtime.dll" Alias "stdInitializeNetwork" _ (ByVal NetworkFilename As String) As Long Declare Function ProcessInputVector _ Lib "Runtime.dll" Alias "stdProcessInputVector" _ (ByVal NetHandle As Long, ByRef InVal As Single, ByRef OutVal As Single) _ As Long Declare Sub TerminateNetwork _ Lib "Runtime.dll" Alias "stdTerminateNetwork" _ (ByVal NetHandle As Long) Note that you declare the function InitializeNetwork but that this refers to the function stdInitializeNetwork in the dll, which is the one you want. Ditto for the other two. Now here is sample code to run the network:
Private Sub Command1_Click()
Dim inputs(1) As Single
Dim outputs(3) As Single
Dim prompt As String
NetHandle = InitializeNetwork("logic.net")
inputs(0) = 0
inputs(1) = 1
result = ProcessInputVector(NetHandle, inputs(0), outputs(0))
prompt = "Output values are " & outputs(0) & " " _
& outputs(1) & " " _
& outputs(2) & " " & outputs(3)
MsgBox (prompt)
TerminateNetwork (NetHandle)
End Sub
VBTest.zip - an example of using the BrainMaker Professional Runtime system in VB. The runtime dll lets you use trained networks with large numbers of inputs and outputs. logic.net has 2 inputs and 4 outputs. The function ProcessInputVectors takes the network handle and two vectors, one for the inputs and one for the outputs; these vectors can be quite long. In the example code, it looks like only one input is being passed, because you pass "inputs(0)" instead of the whole vector "inputs"; remember, however, that Visual Basic passes arguments by reference (that's what ByRef means), so inputs(0) is the address of the entire inputs vector, and similarly for outputs. So in your application, you still pass inputs(0) as in the example code, but inputs and outputs must be dimensioned large enough to hold all the inputs and outputs. |
| Home | Applications | What Are Neural Networks | Products | Ordering Info | Tech Support | |
| California Scientific BrainMaker Neural Network Software | ||||||