📄 参考vb批处理神经网络.frm.txt
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "批处理神经网络"
ClientHeight = 6405
ClientLeft = 60
ClientTop = 345
ClientWidth = 9465
LinkTopic = "Form1"
ScaleHeight = 6405
ScaleWidth = 9465
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "运行计算"
Height = 375
Left = 6000
TabIndex = 17
Top = 5280
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "网络初始化"
Height = 375
Left = 6000
TabIndex = 16
Top = 4560
Width = 1575
End
Begin VB.Frame Frame2
Caption = "数据输入"
Height = 2055
Left = 360
TabIndex = 11
Top = 4080
Width = 4935
Begin VB.TextBox Text1
Height = 375
Index = 6
Left = 2640
TabIndex = 15
Top = 1200
Visible = 0 'False
Width = 1935
End
Begin VB.TextBox Text1
Height = 375
Index = 5
Left = 2640
TabIndex = 14
Top = 480
Width = 1935
End
Begin VB.Label Label1
Caption = "学习步长:"
Height = 375
Index = 6
Left = 120
TabIndex = 13
Top = 600
Width = 1455
End
Begin VB.Label Label1
Caption = "学习次数:"
Height = 375
Index = 5
Left = 120
TabIndex = 12
Top = 1320
Width = 1455
End
End
Begin VB.Frame Frame1
Caption = "数据输入"
Height = 3375
Left = 360
TabIndex = 0
Top = 600
Width = 4935
Begin VB.TextBox Text1
Height = 375
Index = 4
Left = 2640
TabIndex = 10
Top = 2760
Width = 1935
End
Begin VB.TextBox Text1
Height = 375
Index = 3
Left = 2640
TabIndex = 9
Top = 2040
Width = 1935
End
Begin VB.TextBox Text1
Height = 375
Index = 2
Left = 2640
TabIndex = 8
Top = 1440
Width = 1935
End
Begin VB.TextBox Text1
Height = 375
Index = 1
Left = 2640
TabIndex = 7
Top = 840
Width = 1935
End
Begin VB.TextBox Text1
Height = 375
Index = 0
Left = 2640
TabIndex = 6
Top = 240
Width = 1935
End
Begin VB.Label Label1
Caption = "容许误差:"
Height = 375
Index = 4
Left = 240
TabIndex = 5
Top = 2880
Width = 1455
End
Begin VB.Label Label1
Caption = "输出层节点个数:"
Height = 375
Index = 3
Left = 240
TabIndex = 4
Top = 2280
Width = 1455
End
Begin VB.Label Label1
Caption = "隐含层节点个数:"
Height = 375
Index = 2
Left = 240
TabIndex = 3
Top = 1560
Width = 1455
End
Begin VB.Label Label1
Caption = "输入层节点个数:"
Height = 375
Index = 1
Left = 240
TabIndex = 2
Top = 960
Width = 1455
End
Begin VB.Label Label1
Caption = "数据样本的组数:"
Height = 375
Index = 0
Left = 240
TabIndex = 1
Top = 360
Width = 1455
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
'本程序的收敛标准为每个样本组对应的各个输出节点的误差要满足给定的精度要求
'界面控件定位
For i = 0 To 6
Label1(i).Left = 500
Label1(i).Height = 500
Label1(i).Width = 2000
Text1(i).Left = 2650
Text1(i).Height = 350
Text1(i).Width = 1500
Text1(i).Text = " "
Next i
End Sub
Private Sub Command1_Click()
RecordNumber = Val(Text1(0).Text)
InputNumber = Val(Text1(1).Text)
HideNumber = Val(Text1(2).Text)
OutputNumber = Val(Text1(3).Text)
wucha = Val(Text1(4).Text)
pace = Val(Text1(5).Text)
ReDim thresholdhide(HideNumber) '储存隐含节点阈值
ReDim thresholdoutput(OutputNumber) '储存输出节点阈值
ReDim max(InputNumber + OutputNumber) '储存每列输入数据最大值
ReDim Tempinputdata(RecordNumber, InputNumber + OutputNumber) '储存临时输入数据
ReDim standardinputdata(RecordNumber, InputNumber + OutputNumber) '储存归一化后输入数据
ReDim hidedata(RecordNumber, HideNumber) '储存隐含节点输出值
ReDim outputdata(RecordNumber, OutputNumber) '储存输出节点输出值
ReDim wuchaoutput(RecordNumber, OutputNumber) As Single '储存输出层的传播误差
ReDim wuchahide(RecordNumber, HideNumber) As Single '储存隐含层的传播误差
ReDim WIH(InputNumber, HideNumber) '储存输入层隐含层间权重
ReDim WHO(HideNumber, OutputNumber) As Single '储存隐含层输出层间权重
ReDim expect(RecordNumber, OutputNumber) '储存每组数据的期望输出值
Open "F:\批处理神经网络\Prawdata.txt" For Input As #1
For p = 1 To RecordNumber
For i = 1 To InputNumber + OutputNumber
Input #1, Tempinputdata(p, i)
Next i
Next p
Close #1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'复制一个初始数组矩阵
For p = 1 To RecordNumber
For i = 1 To InputNumber + OutputNumber
standardinputdata(p, i) = Tempinputdata(p, i)
Next i
Next p
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'仅做测试用
Open "F:\批处理神经网络\P.txt" For Output As #1
m = 0
For p = 1 To RecordNumber
For i = 1 To InputNumber + OutputNumber
Print #1, Tempinputdata(p, i);
m = m + 1
If m Mod (InputNumber + OutputNumber) = 0 Then
Print #1,
End If
Next i
Next p
Close #1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'求每列的最大值
For i = 1 To InputNumber + OutputNumber
For p = RecordNumber To 2 Step -1
For k = 1 To p - 1
If Tempinputdata(k, i) > Tempinputdata(k + 1, i) Then
Temp = Tempinputdata(k + 1, i)
Tempinputdata(k + 1, i) = Tempinputdata(k, i)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -