This commit is contained in:
ton
2023-09-23 09:57:40 +07:00
parent 0112e6e1be
commit c165afaa11
3 changed files with 10 additions and 6 deletions

View File

@@ -44,6 +44,7 @@ function (kfn::kfn_1)(input::AbstractArray)
kfn.on_epsilonRec .= 0 kfn.on_epsilonRec .= 0
kfn.on_wOutChange .= 0 kfn.on_wOutChange .= 0
kfn.on_refractoryCounter .= 0 kfn.on_refractoryCounter .= 0
kfn.on_firingCounter .= 0
kfn.on_synapticActivityCounter .= 0 kfn.on_synapticActivityCounter .= 0
kfn.learningStage = [2] kfn.learningStage = [2]

View File

@@ -284,7 +284,10 @@ end
function learn!(kfn::kfn_1, progress, device=cpu) function learn!(kfn::kfn_1, progress, device=cpu)
if sum(kfn.timeStep) == 800 if sum(kfn.timeStep) == 800
println("zitCumulative ", sum(kfn.zitCumulative[:,:,784:size(kfn.zitCumulative, 3)], dims=3)) println("zitCumulative ", sum(kfn.zitCumulative[:,:,784:size(kfn.zitCumulative, 3)], dims=3))
# println("on_synapticActivityCounter ", kfn.on_synapticActivityCounter[:,:,1,:]) println("on_synapticActivityCounter 0 ", kfn.on_synapticActivityCounter[:,:,1])
println("on_synapticActivityCounter 5 ", kfn.on_synapticActivityCounter[:,:,6])
println("wOut 0 ", sum(kfn.on_wOut[:,:,1,1], dims=3))
println("wOut 5 ", sum(kfn.on_wOut[:,:,1,1], dims=3))
end end
#WORKING compare output neuron 0 synapse activity when input are label 0 and 5, (!isequal).(wOut) #WORKING compare output neuron 0 synapse activity when input are label 0 and 5, (!isequal).(wOut)
@@ -471,7 +474,7 @@ function neuroplasticity(synapseConnectionNumber,
synapticActivityCounter, synapticActivityCounter,
progress,) # (row, col, n) progress,) # (row, col, n)
if progress == 2 # no need to learn if progress == 2 # no need to learn for current neural pathway
# skip neuroplasticity # skip neuroplasticity
#TODO I may need to do something with neuronInactivityCounter and other variables #TODO I may need to do something with neuronInactivityCounter and other variables
wRecChange .= 0 wRecChange .= 0
@@ -498,8 +501,8 @@ function neuroplasticity(synapseConnectionNumber,
synapseReconnectDelay, synapseConnectionNumber, zitCumulative) synapseReconnectDelay, synapseConnectionNumber, zitCumulative)
# error("DEBUG -> neuroplasticity 1") # error("DEBUG -> neuroplasticity 1")
elseif progress == 0 # no progress, no weight update, only rewire elseif progress == 0 # no progress, no weight update, only rewire
# -w all non-fire connection except mature connection # #TESTING -w all non-fire connection except mature connection
weakenNotMatureSynapse!(wRec, synapticActivityCounter, eta) # weakenNotMatureSynapse!(wRec, synapticActivityCounter, eta)
# prune weak synapse # prune weak synapse
pruneSynapse!(wRec, synapticActivityCounter, synapseReconnectDelay) pruneSynapse!(wRec, synapticActivityCounter, synapseReconnectDelay)

View File

@@ -336,7 +336,7 @@ function kfn_1(params::Dict; device=cpu)
kfn.on_zt = zeros(1, 1, n, batch) |> device kfn.on_zt = zeros(1, 1, n, batch) |> device
kfn.on_zt4d = (similar(kfn.on_wOut) .= 0) kfn.on_zt4d = (similar(kfn.on_wOut) .= 0)
kfn.on_refractoryCounter = (similar(kfn.on_wOut) .= 0) kfn.on_refractoryCounter = (similar(kfn.on_wOut) .= 0)
kfn.on_refractoryDuration = (similar(kfn.on_wOut) .= 0) kfn.on_refractoryDuration = (similar(kfn.on_wOut) .= 1)
kfn.on_delta = 1.0 kfn.on_delta = 1.0
kfn.on_tau_m = 100.0 kfn.on_tau_m = 100.0
kfn.on_alpha = (similar(kfn.on_wOut) .= (exp(-kfn.on_delta / kfn.on_tau_m))) kfn.on_alpha = (similar(kfn.on_wOut) .= (exp(-kfn.on_delta / kfn.on_tau_m)))