?? frmnet.frm
字號:
End
Begin VB.VScrollBar VScroll1
Height = 255
Index = 0
Left = 840
TabIndex = 2
Top = 600
Width = 255
End
Begin VB.TextBox txtNode
Height = 285
Index = 0
Left = 120
TabIndex = 1
Top = 600
Width = 735
End
Begin VB.Label lblNode3
Caption = "輸出層:"
Height = 255
Index = 1
Left = 2280
TabIndex = 12
Top = 360
Width = 615
End
Begin VB.Label lblNode2
Caption = "中間層:"
Height = 255
Left = 1200
TabIndex = 11
Top = 360
Width = 615
End
Begin VB.Label lblNode1
Caption = "輸入層:"
Height = 255
Index = 0
Left = 120
TabIndex = 10
Top = 360
Width = 615
End
End
Begin VB.Image Image1
Height = 165
Left = 2040
Picture = "frmNet.frx":289C
Top = 3120
Width = 495
End
Begin VB.Label Label2
Caption = "數(shù)據(jù)項操作顯示區(qū)"
ForeColor = &H000000FF&
Height = 255
Index = 2
Left = 480
TabIndex = 46
Top = 3120
Width = 1575
End
Begin VB.Menu mnuNetwork
Caption = "網(wǎng)絡(luò)(&N)"
Begin VB.Menu mnuNew
Caption = "新建(&N)"
End
Begin VB.Menu mnuOpen
Caption = "打開(&O)"
End
Begin VB.Menu mnuSep
Caption = "-"
End
Begin VB.Menu mnuSave
Caption = "保存(&S)"
End
Begin VB.Menu mnuSaveas
Caption = "另存為(&A)"
End
Begin VB.Menu mnuSep2
Caption = "-"
End
Begin VB.Menu mnuExit
Caption = "退出(&E)"
End
End
Begin VB.Menu mnuData
Caption = "數(shù)據(jù)(&D)"
Begin VB.Menu mnuShowInTrainData
Caption = "顯示輸入樣本數(shù)據(jù)(&I)"
End
Begin VB.Menu mnuShowOutTrainData
Caption = "顯示輸出樣本數(shù)據(jù)(&O)"
End
Begin VB.Menu mnuShowTestData
Caption = "顯示測試數(shù)據(jù)(&T)"
End
Begin VB.Menu mnuShowTestResult
Caption = "顯示測試結(jié)果(&R)"
End
Begin VB.Menu mnuSep7
Caption = "-"
End
Begin VB.Menu mnuSaveData
Caption = "保存數(shù)據(jù)文件(&S)"
End
End
Begin VB.Menu mnuTask
Caption = "任務(wù)(&T)"
Begin VB.Menu mnuStartTrain
Caption = "開始訓練(&S)"
End
Begin VB.Menu mnuStopTrain
Caption = "停止訓練(&O)"
End
Begin VB.Menu mnuTest
Caption = "開始仿真(&M)"
End
Begin VB.Menu mnuSep3
Caption = "-"
End
Begin VB.Menu mnuUnitary
Caption = "歸一化處理"
End
End
Begin VB.Menu mnuView
Caption = "視圖(&V)"
Begin VB.Menu mnuErrorDis
Caption = "誤差分析圖(&C)"
End
Begin VB.Menu mnuSep5
Caption = "-"
End
Begin VB.Menu mnuOption
Caption = "選項(&O)"
End
End
Begin VB.Menu mnuHelp
Caption = "幫助(&H)"
Begin VB.Menu mnuContent
Caption = "內(nèi)容(&C)"
End
Begin VB.Menu mnuReg
Caption = "注冊(R)"
End
Begin VB.Menu mnuSep6
Caption = "-"
End
Begin VB.Menu mnuAbout
Caption = "關(guān)于(A)"
End
End
End
Attribute VB_Name = "frmNetwork"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private OperIsNew As Boolean '當前操作狀態(tài)是否是新建網(wǎng)絡(luò)模型
Private LmNet As nnToolKit.nnToolKit 'LmNet對象實例
Private Sub Form_Load()
On Error GoTo Handle_Error
Set LmNet = New nnToolKit.nnToolKit
OperIsNew = True
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub mnuAbout_Click()
frmAbout.Show
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub mnuNew_Click()
CBpnFile.Class_Initialize
If OperIsNew <> True Then
MsgBox ("是否保存現(xiàn)有的網(wǎng)絡(luò)模型?")
End If
OperIsNew = True
NetModel_Init
If NetModel_Load() Then
OperStatus_Show ("新建網(wǎng)絡(luò)模型操作完成!")
End If
End Sub
'打開現(xiàn)有網(wǎng)絡(luò)文件
Private Sub mnuOpen_Click()
Dim FileLength1 As String
Dim FileLength2 As String
On Error GoTo Handle_Error
CBpnFile.Class_Initialize
OperIsNew = False
CommonDialog1.Filter = "神經(jīng)網(wǎng)絡(luò)模型文件(*.bpn)|*.bpn"
CommonDialog1.ShowOpen
BpnFileName = CommonDialog1.FileName
FileName = CommonDialog1.FileTitle
FileLength1 = Len(BpnFileName)
FileLength2 = Len(FileName)
FilePath = Left(BpnFileName, FileLength1 - FileLength2)
FilePre = Left(FileName, FileLength2 - 4)
'說明:下面文件中的"1"指的是當前模型編號為1,若用戶要用到多個神經(jīng)網(wǎng)絡(luò)模型時,該外應(yīng)該用一個變量來替代.
InTrainFile = "input_para1.txt"
OutTrainFile = "output_para1.txt"
InSimuFile = "simu_data1.txt"
OutSimuFile = "result1.dat"
SpecifyBpn (BpnFileName)
Nodes(0) = ReadInt("NetPara", "InputNum")
Nodes(1) = ReadInt("NetPara", "OutputNum")
Nodes(2) = ReadInt("NetPara", "MidNum")
ModelNo = ReadInt("NetPara", "ModelNo")
TrainSampleNum = ReadInt("OtherPara", "TrainSampleNum")
SimuSampleNum = ReadInt("OtherPara", "SimuSampleNum")
TransFunc(0) = ReadString("TrainPara", "inputFunc", 9)
TransFunc(1) = ReadString("TrainPara", "outputFunc", 9)
TrainPara(0) = ReadString("TrainPara", "df", 9)
TrainPara(1) = ReadString("TrainPara", "me", 9)
TrainPara(2) = ReadString("TrainPara", "eg", 9)
TrainPara(3) = ReadString("TrainPara", "lr", 9)
TrainPara(4) = ReadString("TrainPara", "lrInc", 9)
TrainPara(5) = ReadString("TrainPara", "lrIdec", 9)
TrainPara(6) = ReadString("TrainPara", "momConst", 9)
TrainPara(7) = ReadString("TrainPara", "errRatio", 9)
If NetModel_Load() Then
OperStatus_Show ("打開現(xiàn)有網(wǎng)絡(luò)模型操作完成!")
Else
ErrorMsg = "初始化神經(jīng)網(wǎng)絡(luò)模型失?。?quot;
End If
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub mnuSave_Click()
On Error GoTo Handle_Error
If BpnFileName = vbNullString Then '如果當前模型文件不存在
CommonDialog1.Filter = "神經(jīng)網(wǎng)絡(luò)模型文件(*.bpn)|*.bpn"
CommonDialog1.ShowSave
BpnFileName = CommonDialog1.FileName
NetFile_Create (BpnFileName)
End If
NetPara_Save
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub mnuSaveas_Click()
On Error GoTo Handle_Error
CommonDialog1.Filter = "神經(jīng)網(wǎng)絡(luò)模型文件(*.bpn)|*.bpn"
CommonDialog1.ShowSave
BpnFileName = CommonDialog1.FileName
NetFile_Create (BpnFileName)
NetPara_Save
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
'保存當前編輯的數(shù)據(jù)文件
Private Sub mnuSaveData_Click()
On Error GoTo Handle_Error
Dim fso As New FileSystemObject, fil As File
fso.CreateTextFile FilePath + CurFileName
rtxtShowResult.SaveFile CurFileName, rtfText
MsgBox ("文件" + CurFileName + "保存成功!")
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub mnuShowInTrainData_Click()
On Error GoTo Handle_Error
CurFileName = InTrainFile
File_Show InTrainFile, "樣本訓練輸入文件"
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub mnuShowOutTrainData_Click()
On Error GoTo Handle_Error
CurFileName = OutTrainFile
File_Show OutTrainFile, "樣本訓練輸出文件"
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub mnuShowTestData_Click()
On Error GoTo Handle_Error
CurFileName = InSimuFile
File_Show InSimuFile, "測試數(shù)據(jù)文件"
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub mnuShowTestResult_Click()
File_Show FilePath + OutSimuFile, "仿真結(jié)果"
End Sub
Private Sub mnuStartTrain_Click()
On Error GoTo Handle_Error
'返回值
Dim retstr As Variant
'網(wǎng)絡(luò)訓練基本參數(shù)
Dim NetTPara(4) As Double
'模型編號
Dim ModelNo As String
'以下為示例參數(shù),實際操作時要求從參數(shù)文件讀出
ModelNo = 1
Nodes(0) = 7
Nodes(1) = 1
Nodes(2) = 28
For i = 0 To 2
NetTPara(i) = Nodes(i)
Next
NetTPara(3) = TrainSampleNum '樣本個數(shù)
'網(wǎng)絡(luò)訓練調(diào)用參數(shù)說明
'1,一個返回參數(shù)
'retstr,返回值
'網(wǎng)絡(luò)模型基本參數(shù),Variant
'神經(jīng)網(wǎng)絡(luò)參數(shù),Double,包括輸入層節(jié)點數(shù);輸出層節(jié)點數(shù);中間層節(jié)點數(shù);網(wǎng)絡(luò)訓練樣本個數(shù)。
'神經(jīng)網(wǎng)絡(luò)訓練參數(shù),若為“-1”表示選擇默認參數(shù)
'網(wǎng)絡(luò)仿真時輸入層至中間層的傳遞函數(shù)
'網(wǎng)絡(luò)仿真時中間層至輸出層的傳遞函數(shù)
'程序運行時的當前目錄
Call LmNet.lmtrain(1, retstr, ModelNo, NetTPara, -1, TransFunc(0), TransFunc(1), FilePath)
MsgBox ("訓練完成,您現(xiàn)在可以進行仿真操作了!")
OperStatus_Show ("訓練完成,您現(xiàn)在可以進行仿真操作了!")
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
'網(wǎng)絡(luò)仿真
Private Sub mnuTest_Click()
'神經(jīng)網(wǎng)絡(luò)仿真參數(shù)
Dim SimulatePara(7) As Double
'模型編號
Dim ModelNo As String
ModelNo = "1"
Dim fso As New FileSystemObject, fil As File, ts As TextStream
On Error GoTo Handle_Error
Set fil = fso.GetFile(FilePath + InSimuFile)
Set ts = fil.OpenAsTextStream(ForReading)
DataLine = ts.ReadLine
DataLength = Len(DataLine)
For i = 0 To Nodes(0) - 1
SimulatePara(i) = Trim(Left(DataLine, 5))
DataLength = Len(DataLine)
DataLine = Trim(Right(DataLine, DataLength - 5))
Next
ts.Close
'SimulatePara(0) = 0.9
'SimulatePara(1) = 0.9
'SimulatePara(2) = 0.063
'SimulatePara(3) = 0.9
'SimulatePara(4) = 0.025
'SimulatePara(5) = 0.467
'SimulatePara(6) = 0.9
'網(wǎng)絡(luò)仿真調(diào)用參數(shù)說明
'1,一個返回參數(shù)
'retstr,返回值
'網(wǎng)絡(luò)模型基本參數(shù),Variant
'神經(jīng)網(wǎng)絡(luò)參數(shù),Double,包括輸入層節(jié)點數(shù);輸出層節(jié)點數(shù);中間層節(jié)點數(shù)
'神經(jīng)網(wǎng)絡(luò)仿真參數(shù),若為“-1”表示選擇默認參數(shù)
'網(wǎng)絡(luò)仿真時輸入層至中間層的傳遞函數(shù)
'網(wǎng)絡(luò)仿真時中間層至輸出層的傳遞函數(shù)
'程序運行時的當前目錄
Call LmNet.lmsimu(1, retstr, ModelNo, Nodes, SimulatePara, TransFunc(0), TransFunc(1), FilePath)
OperStatus_Show ("仿真成功,點擊‘數(shù)據(jù)/顯示測試結(jié)果’查看仿真結(jié)果!")
MsgBox ("仿真成功,點擊‘數(shù)據(jù)/顯示測試結(jié)果’查看仿真結(jié)果!")
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub mnuUnitary_Click()
frmUnitary.cbNodeNo.AddItem "1", 0
frmUnitary.cbNodeNo.AddItem "2", 1
frmUnitary.cbChgFunc.AddItem "對數(shù)轉(zhuǎn)換函數(shù)", 0
frmUnitary.cbChgFunc.AddItem "反正切轉(zhuǎn)換函數(shù)", 1
frmUnitary.Show
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -