?? classrecognize.cls
字號:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ClassRecognize"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'class for application/recognize page 299
'-----------------------------export to excel ability-------------------------------
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Dim objSheet As Excel.Worksheet
Dim row As Integer
Dim column As Integer
'******************************************Define constant********************************************
Const INPUT_LAYER = 63 'total input nodes
Const HIDDEN_LAYER = 4 'total hidden nodes
Const OUTPUT_LAYER = 26 'total output nodes
'*****************************************Declare neuron array****************************************
Dim x(1 To INPUT_LAYER) As Single 'input layer x(i) , max i = INPUT_LAYER
Dim z(1 To HIDDEN_LAYER) As Single 'hidden layer z(j), max j = HIDDEN_LAYER
Dim y(1 To OUTPUT_LAYER) As Single 'output layer y(k), max k = OUTPUT_LAYER
Dim t(1 To OUTPUT_LAYER) As Single 'target, t(k), max k = OUTPUT_LAYER
'******************************************Declare weights array***************************************
Dim v(INPUT_LAYER, 1 To HIDDEN_LAYER) As Single 'to store V(i,j), weight between input and hidden layers
'v(0, 1), v(0,2)....v(0, j) to store bias for z(j)
Dim w(HIDDEN_LAYER, 1 To OUTPUT_LAYER) As Single 'to store W(j,k). weights between input and hidden layers
'w(0,1), w(0,2)...w(0,k) to store bias for y(k)
'******************************Array to store input signal, z_in and y_in*********************************
Dim z_inArray(1 To HIDDEN_LAYER) As Single 'input signal of hidden units
Dim y_inArray(1 To OUTPUT_LAYER) As Single 'input signal of output units
'=========================Input/output Property=====================
'********************************Initialize weights to trained weights, step 0********************************
Public Property Let setW(j As Integer, k As Integer, inData As Single) 'load w(j,k) , w(0,k) as bias
w(j, k) = inData
End Property
Public Property Let setV(i As Integer, j As Integer, inData As Single) 'load v(i,j) , v(0,k) as bias
v(i, j) = inData
End Property
'***************************step 2 of application, function to get input***********************************
Public Property Let setInput(i As Integer, inData As Single) 'load test input, i= 1 to input_layer
x(i) = inData
End Property
Public Property Let setTarget(k As Integer, inData As Single) 'load test input, i= 1 to input_layer
t(k) = inData
End Property
'======================End input property==========================
Public Function compareTarget() As Single 'compare with target to get result
Dim k As Integer
Dim result As Single
result = 0
For k = 1 To OUTPUT_LAYER
result = result + (y(k) - t(k))
Next k
compareTarget = result
End Function
'*********************functions to calc z_in(j), y_in(k), step 3, step 4, page 299*********************
Private Function z_in(j As Integer) As Single 'return z_in(j) , use z_inArray to store calculated value
'z_in(j) = v(0, j) + summation(i=1 to n)[x(i)*v(i,j)]
Dim sum As Single
Dim i As Integer
'sum = v(0,j) = bias
sum = v(0, j)
'sum = sum + summation(i=1 to n)[x(i)*v(i,j)]
For i = 1 To INPUT_LAYER
sum = sum + (x(i) * v(i, j))
Next i
'return sum
z_in = sum
End Function
Private Function y_in(k As Integer) As Single 'return y_in(k), use y_inArray to store calculated value
'y_in(j) = w(0, k) + summation(j=1 to p)[z(j)*v(j,k)]
Dim sum As Single
Dim j As Integer
sum = w(0, k)
For j = 1 To HIDDEN_LAYER
sum = sum + (z(j) * w(j, k))
Next j
y_in = sum
End Function
'*******feedforward***********************
'======step 3===========
Public Function calc_z_in()
Dim j As Integer
For j = 1 To HIDDEN_LAYER
z_inArray(j) = z_in(j)
Next j
End Function
Public Function calcZ()
Dim j As Integer
For j = 1 To HIDDEN_LAYER
z(j) = sigmoid(z_inArray(j))
Next j
End Function
'========step 4==========
Public Function calc_y_in()
Dim k As Integer
For k = 1 To OUTPUT_LAYER
y_inArray(k) = y_in(k)
Next k
End Function
Public Function calcY()
Dim k As Integer
For k = 1 To OUTPUT_LAYER
y(k) = sigmoid(y_inArray(k))
Next k
End Function
'*******************************other functions******************************************
Public Function exportExcel()
Set objExcel = New Excel.Application
'Call addSheet
'objSheet.cells(row, column) = value
Call showExcel
'closing
Set objSheet = Nothing
End Function
Public Function addSheet() 'create a new sheet and set to objSheet
row = 2
column = 1
Set objWorkBook = objExcel.Workbooks.Add
Set objSheet = objWorkBook.Sheets(1)
End Function
Public Function showExcel()
objExcel.Visible = True
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -