refractoring
This commit is contained in:
50
src/learn.jl
50
src/learn.jl
@@ -23,41 +23,41 @@ end
|
||||
""" knowledgeFn learn()
|
||||
"""
|
||||
function learn!(kfn::kfn_1, correctAnswer::BitVector)
|
||||
# # compute kfn error for each neuron
|
||||
# outs = [n.z_t1 for n in kfn.outputNeuronsArray]
|
||||
# for (i, out) in enumerate(outs)
|
||||
# if out != correctAnswer[i] # need to adjust weight
|
||||
# kfnError = ( (kfn.outputNeuronsArray[i].v_th - kfn.outputNeuronsArray[i].vError) *
|
||||
# 100 / kfn.outputNeuronsArray[i].v_th )
|
||||
|
||||
# Threads.@threads for n in kfn.neuronsArray
|
||||
# # for n in kfn.neuronsArray
|
||||
# learn!(n, kfnError)
|
||||
# end
|
||||
|
||||
# learn!(kfn.outputNeuronsArray[i], kfnError)
|
||||
# end
|
||||
# end
|
||||
|
||||
#TESTING compute kfn error for each neuron
|
||||
# compute kfn error for each neuron
|
||||
outs = [n.z_t1 for n in kfn.outputNeuronsArray]
|
||||
for (i, out) in enumerate(outs)
|
||||
if out != correctAnswer[i] # need to adjust weight
|
||||
kfnError = ( (kfn.outputNeuronsArray[i].v_th - kfn.outputNeuronsArray[i].vError) *
|
||||
100 / kfn.outputNeuronsArray[i].v_th )
|
||||
if correctAnswer[i] == 1 # output neuron that associated with correctAnswer
|
||||
Threads.@threads for n in kfn.neuronsArray
|
||||
# for n in kfn.neuronsArray
|
||||
learn!(n, kfnError)
|
||||
end
|
||||
|
||||
learn!(kfn.outputNeuronsArray[i], kfnError)
|
||||
else # output neuron that is NOT associated with correctAnswer
|
||||
learn!(kfn.outputNeuronsArray[i], kfnError)
|
||||
Threads.@threads for n in kfn.neuronsArray
|
||||
# for n in kfn.neuronsArray
|
||||
learn!(n, kfnError)
|
||||
end
|
||||
|
||||
learn!(kfn.outputNeuronsArray[i], kfnError)
|
||||
end
|
||||
end
|
||||
|
||||
# #TESTING compute kfn error for each neuron
|
||||
# outs = [n.z_t1 for n in kfn.outputNeuronsArray]
|
||||
# for (i, out) in enumerate(outs)
|
||||
# if out != correctAnswer[i] # need to adjust weight
|
||||
# kfnError = ( (kfn.outputNeuronsArray[i].v_th - kfn.outputNeuronsArray[i].vError) *
|
||||
# 100 / kfn.outputNeuronsArray[i].v_th )
|
||||
# if correctAnswer[i] == 1 # output neuron that associated with correctAnswer
|
||||
# Threads.@threads for n in kfn.neuronsArray
|
||||
# # for n in kfn.neuronsArray
|
||||
# learn!(n, kfnError)
|
||||
# end
|
||||
|
||||
# learn!(kfn.outputNeuronsArray[i], kfnError)
|
||||
# else # output neuron that is NOT associated with correctAnswer
|
||||
# learn!(kfn.outputNeuronsArray[i], kfnError)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# wrap up learning session
|
||||
if kfn.learningStage == "end_learning"
|
||||
Threads.@threads for n in kfn.neuronsArray
|
||||
|
||||
Reference in New Issue
Block a user