我开始为神经网络编写代码。
训练数据集位于 Excel 工作表中 - 两个输入和两个输出。
我正在努力将数据导入 VBA,以便可以训练网络。
训练部分代码
Private Sub Train_Click()
alpha = 0.3
mu = 0.8
n = 4
m = 4
Dim I, J, K As Integer
Dim TrainError As Double
Dim TrainingData As String
NumCases = 123
For J = 0 To NumCases - 1
For I = 0 To m
X1(J, I) = Sheets("Sheet1").Cells(I, J).String
Next I
targval(J) = X1(J, n)
Next J
Call Init(n, m)
J = 0
Do Until J = 1000 And TrainError = 0
For I = 0 To NumCases - 1
For K = 0 To n - 1
InputNeuron(K) = X1(I, K)
Next
Call HiddenInput(n, m)
Call HiddenTransfer(m)
Call OutputInput(m)
Call OutputTransfer
Call UpdateOut(I, m)
Call UpdateHidden(n, m)
TrainError = TrainError + (targval(I) - oout) ^ 2
Next I
TrainError = Sqrt(TrainError / NumCases)
If TrainError < 0.01 Then
Exit Do
End If
J = J + 1
Loop
End Sub