diff --git a/src/Ironpen.jl b/src/Ironpen.jl index b4ec739..64af8d3 100644 --- a/src/Ironpen.jl +++ b/src/Ironpen.jl @@ -34,10 +34,9 @@ using .interface """ Todo: - [1] implement connection strength based on right or wrong answer - [2] during 0 training if 1-9 output neuron fires, adjust weight only those neurons - [3] implement dormant connection - [4] Δweight * connection strength + [2] implement connection strength based on right or wrong answer + [4] implement dormant connection + [3] Δweight * connection strength [] using RL to control learning signal [] consider using Dates.now() instead of timestamp because time_stamp may overflow [5] training should include adjusting α, neuron membrane potential decay factor @@ -62,6 +61,7 @@ using .interface [DONE] wRec should not normalized whole. it should be local 5 conn normalized. [DONE] neuroplasticity() i.e. change connection [DONE] add multi threads + [DONE] during 0 training if 1-9 output neuron fires, adjust weight only those neurons Change from version: v06_36a - diff --git a/src/learn.jl b/src/learn.jl index a314875..32bc42a 100644 --- a/src/learn.jl +++ b/src/learn.jl @@ -23,19 +23,38 @@ end """ knowledgeFn learn() """ function learn!(kfn::kfn_1, correctAnswer::BitVector) - # compute kfn error + # # 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 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 - Threads.@threads for n in kfn.neuronsArray - # for n in kfn.neuronsArray - learn!(n, kfnError) + learn!(kfn.outputNeuronsArray[i], kfnError) + else # output neuron that is NOT associated with correctAnswer + learn!(kfn.outputNeuronsArray[i], kfnError) end - - learn!(kfn.outputNeuronsArray[i], kfnError) end end