add neuroplasticity for output neuron

This commit is contained in:
2023-05-21 15:55:40 +07:00
parent 4522d10142
commit d3d47d1114
5 changed files with 54 additions and 17 deletions

View File

@@ -60,7 +60,7 @@ function (kfn::kfn_1)(m::model, input_data::AbstractVector)
for i in 1:length(input_data)]
# noise = [rand(rng, Distributions.Binomial(1, 0.5)) for i in 1:10] # another option
input_data = [noise; input_data] # noise start from neuron id 1
input_data = [noise; input_data] # noise must start from neuron id 1
for n in kfn.neuronsArray
timestep_forward!(n)
@@ -218,13 +218,13 @@ function (n::linearNeuron)(kfn::T) where T<:knowledgeFn
# decay of v_t1
n.v_t1 = n.alpha * n.v_t
n.vError = n.v_t1
n.vError = n.v_t1 # store voltage that will be used to calculate error later
else
n.recSignal = sum(n.wRec .* n.z_i_t) # signal from other neuron that this neuron subscribed
n.alpha_v_t = n.alpha * n.v_t
n.v_t1 = n.alpha_v_t + n.recSignal
n.v_t1 = no_negative!(n.v_t1)
n.vError = n.v_t1
n.vError = n.v_t1 # store voltage that will be used to calculate error later
if n.v_t1 > n.v_th
n.z_t1 = true
n.refractoryCounter = n.refractoryDuration