From d9c202ae97948dc6ea54c650f2823f51e5a1d2c2 Mon Sep 17 00:00:00 2001 From: ton Date: Fri, 18 Aug 2023 10:06:01 +0700 Subject: [PATCH] fix --- src/forward.jl | 5 +++++ src/learn.jl | 6 +++--- src/type.jl | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/forward.jl b/src/forward.jl index 7db6ce7..e806051 100644 --- a/src/forward.jl +++ b/src/forward.jl @@ -22,16 +22,21 @@ function (kfn::kfn_1)(input::AbstractArray) kfn.lif_wRecChange .= 0 kfn.lif_epsilonRec .= 0 kfn.lif_firingCounter .= 0 + kfn.lif_refractoryCounter .= 0 + kfn.lif_zt .= 0 kfn.alif_vt .= 0 kfn.alif_epsilonRec .= 0 kfn.alif_epsilonRecA .= 0 kfn.alif_wRecChange .= 0 kfn.alif_firingCounter .= 0 + kfn.alif_refractoryCounter .= 0 + kfn.alif_zt .= 0 kfn.on_vt .= 0 kfn.on_epsilonRec .= 0 kfn.on_wOutChange .= 0 + kfn.on_refractoryCounter .= 0 kfn.learningStage = [2] end diff --git a/src/learn.jl b/src/learn.jl index 3dcd27b..fb81822 100644 --- a/src/learn.jl +++ b/src/learn.jl @@ -93,7 +93,7 @@ function lifComputeParamsChange!( timeStep::CuArray, wRecChange .+= (-eta .* nError .* eRec) # frequency regulator - wRecChange .+= 0.0001 .* ((firingTargetFrequency - (firingCounter./timeStep)) .* timeStep) .* + wRecChange .+= 0.001 .* ((firingTargetFrequency - (firingCounter./timeStep)) ./ timeStep) .* eta .* eRec # if sum(timeStep) == 785 @@ -149,7 +149,7 @@ function alifComputeParamsChange!( timeStep::CuArray, wRecChange .+= (-eta .* nError .* eRec) # frequency regulator - wRecChange .+= 0.0001 .* ((firingTargetFrequency - (firingCounter./timeStep)) .* timeStep) .* + wRecChange .+= 0.001 .* ((firingTargetFrequency - (firingCounter./timeStep)) ./ timeStep) .* eta .* eRec # reset epsilonRec @@ -171,7 +171,7 @@ function onComputeParamsChange!(phi::CuArray, eRec .= phi .* epsilonRec nError .= reshape(outputError, (1, 1, :, size(outputError, 2))) .* arrayProjection4d - wOutChange .+= (-eta .* nError .* eRec) + wOutChange .+= (-eta .* nError .* eRec) #BUG why wOutChange not increase every timestep that madel get wrong answer? # reset epsilonRec epsilonRec .= 0 diff --git a/src/type.jl b/src/type.jl index 114199e..cd413fe 100644 --- a/src/type.jl +++ b/src/type.jl @@ -191,7 +191,7 @@ function kfn_1(params::Dict; device=cpu) for slice in eachslice(w, dims=3) pool = shuffle!([1:row*col...])[1:synapticConnection] for i in pool - slice[i] = randn()/10 # assign weight to synaptic connection + slice[i] = randn()/10 # assign weight to synaptic connection, start small end end # project 3D w into 4D kfn.lif_wRec (row, col, n, batch)