This commit is contained in:
ton
2023-08-18 10:06:01 +07:00
parent 1bec436408
commit d9c202ae97
3 changed files with 9 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)