From c165afaa11978b423e9498e7eb7aed15036bd600 Mon Sep 17 00:00:00 2001 From: ton Date: Sat, 23 Sep 2023 09:57:40 +0700 Subject: [PATCH] dev --- src/forward.jl | 3 ++- src/learn.jl | 11 +++++++---- src/type.jl | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/forward.jl b/src/forward.jl index 76e13d1..12b4191 100644 --- a/src/forward.jl +++ b/src/forward.jl @@ -44,6 +44,7 @@ function (kfn::kfn_1)(input::AbstractArray) kfn.on_epsilonRec .= 0 kfn.on_wOutChange .= 0 kfn.on_refractoryCounter .= 0 + kfn.on_firingCounter .= 0 kfn.on_synapticActivityCounter .= 0 kfn.learningStage = [2] @@ -140,7 +141,7 @@ function (kfn::kfn_1)(input::AbstractArray) kfn.on_zit .= reshape(kfn.zit, (i1, i2, 1, i4)) .* kfn.on_arrayProjection4d # read out - onForward( kfn.on_zit, + onForward( kfn.on_zit, kfn.on_wOut, kfn.on_vt, kfn.on_vth, diff --git a/src/learn.jl b/src/learn.jl index 3410723..42e09b7 100644 --- a/src/learn.jl +++ b/src/learn.jl @@ -284,7 +284,10 @@ end function learn!(kfn::kfn_1, progress, device=cpu) if sum(kfn.timeStep) == 800 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 #WORKING compare output neuron 0 synapse activity when input are label 0 and 5, (!isequal).(wOut) @@ -471,7 +474,7 @@ function neuroplasticity(synapseConnectionNumber, synapticActivityCounter, progress,) # (row, col, n) - if progress == 2 # no need to learn + if progress == 2 # no need to learn for current neural pathway # skip neuroplasticity #TODO I may need to do something with neuronInactivityCounter and other variables wRecChange .= 0 @@ -498,8 +501,8 @@ function neuroplasticity(synapseConnectionNumber, synapseReconnectDelay, synapseConnectionNumber, zitCumulative) # error("DEBUG -> neuroplasticity 1") elseif progress == 0 # no progress, no weight update, only rewire - # -w all non-fire connection except mature connection - weakenNotMatureSynapse!(wRec, synapticActivityCounter, eta) + # #TESTING -w all non-fire connection except mature connection + # weakenNotMatureSynapse!(wRec, synapticActivityCounter, eta) # prune weak synapse pruneSynapse!(wRec, synapticActivityCounter, synapseReconnectDelay) diff --git a/src/type.jl b/src/type.jl index ada983e..e776dbf 100644 --- a/src/type.jl +++ b/src/type.jl @@ -336,7 +336,7 @@ function kfn_1(params::Dict; device=cpu) kfn.on_zt = zeros(1, 1, n, batch) |> device kfn.on_zt4d = (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_tau_m = 100.0 kfn.on_alpha = (similar(kfn.on_wOut) .= (exp(-kfn.on_delta / kfn.on_tau_m)))