This commit is contained in:
ton
2023-07-27 10:00:20 +07:00
parent a94354efb3
commit 0da983f493
3 changed files with 159 additions and 53 deletions

View File

@@ -16,6 +16,7 @@ function (kfn::kfn_1)(input::AbstractArray)
#TODO time step forward
if kfn.learningStage == [1]
# reset learning params
kfn.learningStage = [2]
end
d1, d2, d3 = size(input)
@@ -271,6 +272,57 @@ function onForward(kfn_zit,
end
end
# function onForward(kfn_zit,
# zit,
# wOut,
# vt0,
# vt1,
# vth,
# vRest,
# zt1,
# alpha,
# phi,
# epsilonRec,
# refractoryCounter,
# refractoryDuration,
# gammaPd,
# firingCounter)
# d1, d2, d3, d4 = size(wOut)
# zit .= reshape(kfn_zit, (d1, d2, 1, d4)) .* ones(size(wOut)...) # project zit into zit
# for j in 1:d4, i in 1:d3 # compute along neurons axis of every batch
# if view(refractoryCounter, :, :, i, j)[1] > 0 # neuron is inactive (in refractory period)
# view(refractoryCounter, :, :, i, j)[1] -= 1
# view(zt1, :, :, i, j)[1] = 0
# view(vt1, :, :, i, j)[1] =
# view(alpha, :, :, i, j)[1] * view(vt0, :, :, i, j)[1]
# view(phi, :, :, i, j)[1] = 0.0
# view(epsilonRec, :, :, i, j) .= view(alpha, :, :, i, j)[1] .*
# view(epsilonRec, :, :, i, j)
# else # neuron is active
# view(vt1, :, :, i, j)[1] =
# (view(alpha, :, :, i, j)[1] * view(vt0,:, :, i, j)[1]) +
# sum(view(zit, :, :, i, j) .* view(wOut, :, :, i, j))
# if view(vt1, :, :, i, j)[1] > view(vth, :, :, i, j)[1]
# view(zt1, :, :, i, j)[1] = 1
# view(refractoryCounter, :, :, i, j)[1] =
# view(refractoryDuration, :, :, i, j)[1]
# view(firingCounter, :, :, i, j)[1] += 1
# view(vt1, :, :, i, j)[1] = view(vRest, :, :, i, j)[1]
# else
# view(zt1, :, :, i, j)[1] = 0
# end
# # there is a difference from alif formula
# view(phi, :, :, i, j)[1] =
# (view(gammaPd, :, :, i, j)[1] / view(vth, :, :, i, j)[1]) *
# max(0, 1 - ((view(vt1, :, :, i, j)[1] - view(vth, :, :, i, j)[1]) /
# view(vth, :, :, i, j)[1]))
# view(epsilonRec, :, :, i, j) .=
# (view(alpha, :, :, i, j)[1] .* view(epsilonRec, :, :, i, j)) +
# view(zit, :, :, i, j)
# end
# end
# end