⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lab2perceptron.frm

📁 bp, backpropagation 神经网络 简单认字 错误开发实例。
💻 FRM
📖 第 1 页 / 共 4 页
字号:
      Begin VB.TextBox txtDB_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   0
         Left            =   1680
         TabIndex        =   18
         TabStop         =   0   'False
         Top             =   960
         Width           =   495
      End
      Begin VB.TextBox txtDW2_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   0
         Left            =   960
         TabIndex        =   17
         TabStop         =   0   'False
         Top             =   960
         Width           =   495
      End
      Begin VB.TextBox txtDB_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   1
         Left            =   1680
         TabIndex        =   16
         TabStop         =   0   'False
         Top             =   1560
         Width           =   495
      End
      Begin VB.TextBox txtDW2_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   1
         Left            =   960
         TabIndex        =   15
         TabStop         =   0   'False
         Top             =   1560
         Width           =   495
      End
      Begin VB.TextBox txtDW1_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   2
         Left            =   240
         TabIndex        =   14
         TabStop         =   0   'False
         Top             =   2160
         Width           =   495
      End
      Begin VB.TextBox txtDB_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   2
         Left            =   1680
         TabIndex        =   13
         TabStop         =   0   'False
         Top             =   2160
         Width           =   495
      End
      Begin VB.TextBox txtDW2_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   2
         Left            =   960
         TabIndex        =   12
         TabStop         =   0   'False
         Top             =   2160
         Width           =   495
      End
      Begin VB.TextBox txtDW1_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   3
         Left            =   240
         TabIndex        =   11
         TabStop         =   0   'False
         Top             =   2760
         Width           =   495
      End
      Begin VB.TextBox txtDB_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   3
         Left            =   1680
         TabIndex        =   10
         TabStop         =   0   'False
         Top             =   2760
         Width           =   495
      End
      Begin VB.TextBox txtDW2_1 
         Alignment       =   2  'Center
         BackColor       =   &H8000000B&
         Height          =   375
         Index           =   3
         Left            =   960
         TabIndex        =   9
         TabStop         =   0   'False
         Top             =   2760
         Width           =   495
      End
      Begin VB.Label Label4 
         Caption         =   "  ( #W1     #W2        #B )"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   375
         Left            =   240
         TabIndex        =   35
         Top             =   480
         Width           =   2055
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Target"
      Height          =   3495
      Left            =   5280
      TabIndex        =   6
      Top             =   840
      Width           =   735
      Begin VB.TextBox txtTgt_1 
         Alignment       =   2  'Center
         Height          =   375
         Index           =   3
         Left            =   120
         TabIndex        =   3
         Top             =   2760
         Width           =   495
      End
      Begin VB.TextBox txtTgt_1 
         Alignment       =   2  'Center
         Height          =   375
         Index           =   2
         Left            =   120
         TabIndex        =   2
         Top             =   2160
         Width           =   495
      End
      Begin VB.TextBox txtTgt_1 
         Alignment       =   2  'Center
         Height          =   375
         Index           =   1
         Left            =   120
         TabIndex        =   1
         Top             =   1560
         Width           =   495
      End
      Begin VB.TextBox txtTgt_1 
         Alignment       =   2  'Center
         Height          =   375
         Index           =   0
         Left            =   120
         TabIndex        =   0
         Top             =   960
         Width           =   495
      End
      Begin VB.Label Label3 
         Caption         =   "( t )"
         ForeColor       =   &H000000FF&
         Height          =   255
         Left            =   240
         TabIndex        =   34
         Top             =   480
         Width           =   375
      End
   End
   Begin VB.Label Label13 
      Caption         =   "Delta"
      Height          =   255
      Left            =   12000
      TabIndex        =   132
      Top             =   4440
      Width           =   1095
   End
   Begin VB.Label Label11 
      Caption         =   "Learning Rate"
      Height          =   255
      Left            =   12000
      TabIndex        =   131
      Top             =   3600
      Width           =   1095
   End
   Begin VB.Label Label6 
      Caption         =   "Perceptron for the AND function."
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   113
      Top             =   120
      Width           =   5415
   End
   Begin VB.Label Label9 
      Caption         =   "2nd Epoch"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   57
      Top             =   4440
      Width           =   1695
   End
   Begin VB.Label Label1 
      Caption         =   "1st Epoch"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   7
      Top             =   480
      Width           =   1695
   End
End
Attribute VB_Name = "lab2perceptron"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Private Sub cmdAutoValue_Click()
    txtX1_1(0) = 1
    txtX2_1(0) = 1
    txtTgt_1(0) = 1
    txtX1_1(1) = 1
    txtX2_1(1) = -1
    txtTgt_1(1) = -1
    txtX1_1(2) = -1
    txtX2_1(2) = 1
    txtTgt_1(2) = -1
    txtX1_1(3) = -1
    txtX2_1(3) = -1
    txtTgt_1(3) = -1
    
End Sub

Private Sub cmdBBipolar_Click()
    txtX1_1(0) = "1"
    txtX2_1(0) = "1"
    txtTgt_1(0) = "1"
    
    txtX1_1(1) = "1"
    txtX2_1(1) = "0"
    txtTgt_1(1) = "-1"
    
    txtX1_1(2) = "0"
    txtX2_1(2) = "1"
    txtTgt_1(2) = "-1"
    
    txtX1_1(3) = "0"
    txtX2_1(3) = "0"
    txtTgt_1(3) = "-1"
End Sub

Private Sub cmdReset_Click()
cmdRun.Visible = True
cmdReset.Visible = False
For i = 0 To 3
    txtX1_1(i) = ""
    txtX2_1(i) = ""
    txtX1_2(i) = ""
    txtX2_1(i) = ""
    txtX2_2(i) = ""
    txtTgt_1(i) = ""
    txtTgt_2(i) = ""
    txtNet_1(i) = ""
    txtNet_2(i) = ""
    txtOut_1(i) = ""
    txtOut_2(i) = ""
    txtW1_1(i + 1) = ""
    txtW2_1(i + 1) = ""
    txtW2_2(i + 1) = ""
    txtW1_2(i + 1) = ""
    txtW2_1(i + 1) = ""
    txtDW1_1(i) = ""
    txtDW2_1(i) = ""
    txtDW1_2(i) = ""
    txtDW2_1(i) = ""
    txtDW2_2(i) = ""
    txtB_1(i + 1) = ""
    txtB_2(i + 1) = ""
    txtDB_1(i) = ""
    txtDB_2(i) = ""
Next i
    
End Sub

Private Sub cmdRun_Click()
cmdRun.Visible = False
cmdReset.Visible = True
For i = 0 To 3
'step 4
    txtNet_1(i).Text = Val(txtB_1(i).Text) + Val(txtX1_1(i).Text * txtW1_1(i).Text) + Val(txtX2_1(i).Text * txtW2_1(i).Text)
    
    If Val(txtNet_1(i).Text) > Val(txtDelta.Text) Then
    txtOut_1(i).Text = 1
    ElseIf Val(txtNet_1(i).Text) < -Val(txtDelta.Text) Then
    txtOut_1(i).Text = -1
    Else
    txtOut_1(i).Text = 0
    End If
    
'step 5
    If txtOut_1(i).Text = txtTgt_1(i).Text Then
    txtW1_1(i + 1).Text = txtW1_1(i).Text
    txtW2_1(i + 1).Text = txtW1_1(i).Text
    txtB_1(i + 1).Text = txtB_1(i).Text
    Else
    txtW1_1(i + 1).Text = Val(txtW1_1(i).Text) + Val(txtLRate.Text * txtTgt_1(i).Text * txtX1_1(i).Text)
    txtW2_1(i + 1).Text = Val(txtW2_1(i).Text) + Val(txtLRate.Text * txtTgt_1(i).Text * txtX2_1(i).Text)
    txtB_1(i + 1).Text = Val(txtB_1(i).Text) + Val(txtLRate.Text * txtTgt_1(i).Text)
    End If
    txtDW1_1(i).Text = Val(txtW1_1(i + 1).Text) - Val(txtW1_1(i).Text)
    txtDW2_1(i).Text = Val(txtW2_1(i + 1).Text) - Val(txtW2_1(i).Text)
    txtDB_1(i).Text = Val(txtB_1(i + 1).Text) - Val(txtB_1(i).Text)
Next i
    
    txtW1_2(0).Text = txtW1_1(4).Text
    txtW2_2(0).Text = txtW2_1(4).Text
    txtB_2(0).Text = txtB_1(4).Text
For i = 0 To 3
    txtX1_2(i).Text = txtX1_1(i).Text
    txtX2_2(i).Text = txtX2_1(i).Text
    txtTgt_2(i).Text = txtTgt_1(i).Text
Next i
'less step 6
'2nd epoch
For i = 0 To 3
    txtNet_2(i).Text = Val(txtB_2(i).Text) + (Val(txtX1_2(i).Text) * Val(txtW1_2(i).Text)) + (Val(txtX2_2(i).Text) * Val(txtW2_2(i).Text))
    If Val(txtNet_2(i).Text) > 0 Then
    txtOut_2(i).Text = 1
    ElseIf Val(txtNet_2(i).Text) = 0 Then
    txtOut_2(i).Text = 0
    Else
    txtOut_2(i).Text = -1
    End If
    If txtOut_2(i).Text = txtTgt_2(i).Text Then
    txtW1_2(i + 1).Text = txtW1_2(i).Text
    txtW2_2(i + 1).Text = txtW1_2(i).Text
    txtB_2(i + 1).Text = txtB_2(i).Text
    Else
    txtW1_2(i + 1).Text = Val(txtW1_2(i).Text) + Val(1 * txtTgt_2(i).Text * txtX1_2(i).Text)
    txtW2_2(i + 1).Text = Val(txtW2_2(i).Text) + Val(1 * txtTgt_2(i).Text * txtX2_2(i).Text)
    txtB_2(i + 1).Text = Val(txtB_2(i).Text) + Val(1 * txtTgt_2(i).Text)
    End If
    txtDW1_2(i).Text = Val(txtW1_2(i + 1).Text) - Val(txtW1_2(i).Text)
    txtDW2_2(i).Text = Val(txtW2_2(i + 1).Text) - Val(txtW2_2(i).Text)
    txtDB_2(i).Text = Val(txtB_2(i + 1).Text) - Val(txtB_2(i).Text)
Next i

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -