📄 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 + -