?? mainfrm.frm
字號:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form mainFrm
Caption = " 神經網絡-----BP算法的實現"
ClientHeight = 8595
ClientLeft = 60
ClientTop = 345
ClientWidth = 11880
ClipControls = 0 'False
ControlBox = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 8595
ScaleWidth = 11880
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton inputParaCmd
Caption = "導入參數"
Height = 495
Left = 8160
TabIndex = 31
Top = 7920
Width = 1335
End
Begin VB.TextBox Text3
Height = 420
Left = 10200
TabIndex = 29
Text = "Text3"
Top = 3840
Width = 1455
End
Begin VB.CheckBox Check1
Caption = "使用該權值和閾值繼續學習"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 5040
TabIndex = 28
Top = 3600
Width = 2655
End
Begin VB.PictureBox Picture1
BackColor = &H8000000E&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3375
Left = 5040
ScaleHeight = 3315
ScaleWidth = 6555
TabIndex = 26
Top = 4320
Width = 6615
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3015
Left = 5040
MultiLine = -1 'True
TabIndex = 24
Top = 480
Width = 6615
End
Begin VB.Frame Frame2
Caption = "參數調整"
Height = 3735
Left = 120
TabIndex = 10
Top = 120
Width = 4695
Begin VB.CommandButton restudyCmd
Caption = "重新學習"
Height = 375
Left = 3240
TabIndex = 23
Top = 1560
Width = 1215
End
Begin VB.TextBox Txt1
Height = 345
Index = 3
Left = 1800
TabIndex = 21
Text = "1"
Top = 3000
Width = 2535
End
Begin VB.TextBox Txt1
Height = 345
Index = 2
Left = 1800
TabIndex = 19
Text = "1"
Top = 2280
Width = 1335
End
Begin VB.TextBox Txt1
Height = 345
Index = 7
Left = 1800
TabIndex = 17
Text = "1000"
Top = 1680
Width = 1335
End
Begin VB.TextBox Txt1
Height = 345
Index = 6
Left = 1800
TabIndex = 15
Text = "0.001"
Top = 1080
Width = 1335
End
Begin VB.TextBox Txt1
Height = 345
Index = 5
Left = 3480
TabIndex = 13
Text = "0.6"
Top = 480
Width = 975
End
Begin VB.TextBox Txt1
Height = 345
Index = 4
Left = 1440
TabIndex = 11
Text = "0.6"
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "隱含層的神經元數目:"
Height = 615
Index = 8
Left = 240
TabIndex = 22
Top = 3000
Width = 1455
End
Begin VB.Label Label1
Caption = "隱層層數:"
Height = 375
Index = 2
Left = 240
TabIndex = 20
Top = 2280
Width = 1215
End
Begin VB.Label Label1
Caption = "最大學習次數:"
Height = 375
Index = 7
Left = 240
TabIndex = 18
Top = 1680
Width = 1695
End
Begin VB.Label Label1
Caption = "系統允許誤差:"
Height = 375
Index = 6
Left = 240
TabIndex = 16
Top = 1080
Width = 1695
End
Begin VB.Label Label1
Caption = "動量矩:"
Height = 375
Index = 5
Left = 2520
TabIndex = 14
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "學習因子:"
Height = 375
Index = 4
Left = 240
TabIndex = 12
Top = 480
Width = 1215
End
End
Begin MSComDlg.CommonDialog cdg
Left = 11280
Top = 7920
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton saveParaCmd
Caption = "保存參數"
Height = 495
Left = 6600
TabIndex = 6
Top = 7920
Width = 1215
End
Begin VB.CommandButton stopStudyCmd
Caption = "停止學習"
Height = 495
Left = 5040
TabIndex = 5
Top = 7920
Width = 1215
End
Begin VB.Frame Frame1
Caption = "學習樣本管理"
Height = 3735
Left = 120
TabIndex = 4
Top = 3960
Width = 4695
Begin VB.CommandButton saveCmd
Caption = "導出樣本"
Height = 1335
Left = 3960
TabIndex = 9
Top = 2160
Width = 375
End
Begin VB.CommandButton inputSampleCmd
Caption = "導入樣本"
Height = 1335
Left = 3960
TabIndex = 8
Top = 600
Width = 375
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3255
Left = 120
MultiLine = -1 'True
TabIndex = 7
Top = 360
Width = 3495
End
End
Begin VB.CommandButton setParaCmd
Caption = "參數設置"
Height = 495
Left = 360
TabIndex = 3
Top = 7920
Width = 1215
End
Begin VB.CommandButton checkCmd
Caption = "檢 測"
Height = 495
Left = 1920
TabIndex = 2
Top = 7920
Width = 1215
End
Begin VB.CommandButton startStudyCmd
Caption = "開始學習"
Height = 495
Left = 3480
TabIndex = 1
Top = 7920
Width = 1215
End
Begin VB.CommandButton returnCmd
Caption = "返 回"
Height = 495
Left = 9840
TabIndex = 0
Top = 7920
Width = 1215
End
Begin VB.Label Label4
Caption = "本次運算誤差最大值"
Height = 255
Left = 8040
TabIndex = 30
Top = 3840
Width = 2295
End
Begin VB.Label Label3
Caption = "全局誤差變化曲線"
Height = 255
Left = 5040
TabIndex = 27
Top = 3960
Width = 2055
End
Begin VB.Label Label2
Caption = "訓練后的權值W[層數][單元數][維數] 和 閾值[層數][單元數]"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 5040
TabIndex = 25
Top = 120
Width = 5895
End
End
Attribute VB_Name = "mainFrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Compare Text
Private Sub checkCmd_Click()
'checktag = 1
If Text1.Text = "" Then
MsgBox "沒有檢測數據,請先輸入!", vbOKOnly + vbInformation, "信息"
Exit Sub
End If
Text2.Text = ""
Picture1.Cls
Read_Data
OutputData
End Sub
Private Sub OutputData() '參數導入
Dim i, r, s As Long
Dim sumwpb As Double
Dim temp As String
Text2.Text = "輸出結果:"
For i = 1 To midLayerNum + 1 '層數
'/////////////////
For s = 1 To W(i, 0, 0) '神經元數
'If i = 1 And s <= inLayer_R Then
' A(i - 1, s) = P(smpl, s) '將例子輸入給a(0)
'End If
'//////////////////////
sumwpb = 0
For r = 1 To W(i, s, 0) '神經元維數--和輸入例子的維數
sumwpb = sumwpb + W(i, s, r) * A(i - 1, r)
Next r
'//////////////////////
n(i, s) = sumwpb + B(i, s)
A(i, s) = 1 / (1 + Exp(-1 * n(i, s)))
'////////// 統計誤差 /////////////////////////
If i = midLayerNum + 1 Then
temp = Format(A(i, s), "0.########")
Text2.Text = Text2.Text & CStr(temp) & Chr$(13) & Chr(10)
'out_Err(s) = (A(i, s) - T(i, s)) * (A(i, s) - T(i, s)) / 2
'err_curr = err_curr + out_Err(s)
End If
Next s
'//////////////////
Next i
End Sub
Private Sub inputParaCmd_Click() '參數導入
Dim FileNumber As String
Dim str As String
Dim i, j, k As Long
Dim whole As String
cdg.CancelError = True
On Error GoTo ErrHandler
FileNumber = FreeFile
cdg.Flags = cdlOFNHideReadOnly
cdg.Filter = "All Files (*.*)|*.*|Text Files" & _
"(*.txt)|*.txt|Batch Files (*.bat)|*.bat"
cdg.FilterIndex = 2
cdg.ShowOpen
Open cdg.Filename For Input As #FileNumber
Line Input #FileNumber, str$
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -