time-based learning method based on new error formula

This commit is contained in:
2023-05-16 20:56:05 +07:00
parent 114161ba69
commit 70d2521c5e
5 changed files with 146 additions and 227 deletions

View File

@@ -11,7 +11,6 @@ using ..types, ..snn_utils
""" Model forward()
"""
function (m::model)(input_data::AbstractVector)
# m.global_tick += 1
m.timeStep += 1
# process all corresponding KFN
@@ -31,7 +30,6 @@ function (kfn::kfn_1)(m::model, input_data::AbstractVector)
kfn.timeStep = m.timeStep
kfn.softreset = m.softreset
kfn.learningStage = m.learningStage
kfn.error = m.error
# generate noise
noise = [GeneralUtils.randomChoiceWithProb([true, false],[0.5,0.5])
@@ -101,8 +99,8 @@ function (n::lif_neuron)(kfn::knowledgeFn)
# last only 1 timestep follow by a period of refractory.
n.recSignal = n.recSignal * 0.0
# Exponantial decay of v_t1
n.v_t1 = n.v_t * n.alpha^(n.timeStep - n.lastFiringTime) # or n.v_t1 = n.alpha * n.v_t
# decay of v_t1
n.v_t1 = n.alpha * n.v_t
else
n.recSignal = sum(n.w_rec .* n.z_i_t) # signal from other neuron that this neuron subscribed
@@ -142,8 +140,8 @@ function (n::alif_neuron)(kfn::knowledgeFn)
n.a = (n.rho * n.a) + ((1 - n.rho) * n.z_t)
n.recSignal = n.recSignal * 0.0
# Exponantial decay of v_t1
n.v_t1 = n.v_t * n.alpha^(n.timeStep - n.lastFiringTime) # or n.v_t1 = n.alpha * n.v_t
# decay of v_t1
n.v_t1 = n.alpha * n.v_t
n.phi = 0
else
n.z_t = isnothing(n.z_t) ? false : n.z_t
@@ -187,8 +185,8 @@ function (n::linear_neuron)(kfn::T) where T<:knowledgeFn
# last only 1 timestep follow by a period of refractory.
n.recSignal = n.recSignal * 0.0
# Exponantial decay of v_t1
n.v_t1 = n.v_t * n.alpha^(n.timeStep - n.lastFiringTime) # or n.v_t1 = n.alpha * n.v_t
# decay of v_t1
n.v_t1 = n.alpha * n.v_t
else
n.recSignal = sum(n.w_rec .* n.z_i_t) # signal from other neuron that this neuron subscribed