minor fix
This commit is contained in:
@@ -60,9 +60,11 @@ function (kfn::kfn_1)(m::model, input_data::AbstractVector)
|
||||
end
|
||||
|
||||
# generate noise
|
||||
noise = [GeneralUtils.randomChoiceWithProb([true, false],[0.2, 0.8])
|
||||
noise = [GeneralUtils.randomChoiceWithProb([true, false],[0.01, 0.99])
|
||||
for i in 1:length(input_data)]
|
||||
# noise = [rand(rng, Distributions.Binomial(1, 0.5)) for i in 1:10] # another option
|
||||
# noise = [kfn.timeStep % 50 == 0
|
||||
# for i in 1:length(input_data)]
|
||||
|
||||
input_data = [noise; input_data] # noise must start from neuron id 1
|
||||
|
||||
@@ -95,8 +97,8 @@ function (kfn::kfn_1)(m::model, input_data::AbstractVector)
|
||||
|
||||
return sum(kfn.firedNeurons_t1[kfn.kfnParams[:totalInputPort]+1:end])::Int,
|
||||
logit::Array{Float64},
|
||||
[i for i in kfn.neuronsArray[end].wRec[1:10]],
|
||||
[sum(i.wRec) for i in kfn.outputNeuronsArray],
|
||||
[i for i in kfn.neuronsArray[101].wRec[1:10]],
|
||||
[i.v_t1 for i in kfn.neuronsArray[101:110]],
|
||||
[sum(i.epsilonRec) for i in kfn.outputNeuronsArray],
|
||||
[sum(i.wRecChange) for i in kfn.outputNeuronsArray]
|
||||
end
|
||||
@@ -136,6 +138,8 @@ function (n::lifNeuron)(kfn::knowledgeFn)
|
||||
n.epsilonRec = n.decayedEpsilonRec
|
||||
else
|
||||
n.recSignal = sum(n.wRec .* n.z_i_t) # signal from other neuron that this neuron subscribed
|
||||
|
||||
# computeAlpha!(n)
|
||||
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)
|
||||
@@ -152,7 +156,7 @@ function (n::lifNeuron)(kfn::knowledgeFn)
|
||||
# there is a difference from alif formula
|
||||
n.phi = (n.gammaPd / n.v_th) * max(0, 1 - (n.v_t1 - n.v_th) / n.v_th)
|
||||
n.decayedEpsilonRec = n.alpha * n.epsilonRec
|
||||
n.epsilonRec = n.decayedEpsilonRec + n.z_i_t
|
||||
n.epsilonRec = n.decayedEpsilonRec + n.z_i_t
|
||||
end
|
||||
end
|
||||
|
||||
@@ -183,6 +187,7 @@ function (n::alifNeuron)(kfn::knowledgeFn)
|
||||
else
|
||||
n.av_th = n.v_th + (n.beta * n.a)
|
||||
n.recSignal = sum(n.wRec .* n.z_i_t) # signal from other neuron that this neuron subscribed
|
||||
# computeAlpha!(n)
|
||||
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)
|
||||
@@ -215,7 +220,7 @@ function (n::linearNeuron)(kfn::T) where T<:knowledgeFn
|
||||
n.timeStep = kfn.timeStep
|
||||
|
||||
# pulling other neuron's firing status at time t
|
||||
n.z_i_t = getindex(kfn.firedNeurons_t1, n.subscriptionList)
|
||||
n.z_i_t = getindex(kfn.firedNeurons_t0, n.subscriptionList)
|
||||
n.z_i_t_commulative += n.z_i_t
|
||||
|
||||
if n.refractoryCounter != 0
|
||||
@@ -228,18 +233,18 @@ 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 # store voltage that will be used to calculate error later
|
||||
|
||||
n.phi = 0.0
|
||||
n.decayedEpsilonRec = n.alpha * n.epsilonRec
|
||||
n.epsilonRec = n.decayedEpsilonRec
|
||||
n.epsilonRec = n.decayedEpsilonRec
|
||||
else
|
||||
recSignal = n.wRec .* n.z_i_t
|
||||
n.recSignal = sum(recSignal) # signal from other neuron that this neuron subscribed
|
||||
n.recSignal = sum(n.wRec .* n.z_i_t) # signal from other neuron that this neuron subscribed
|
||||
|
||||
# computeAlpha!(n)
|
||||
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 # 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
|
||||
@@ -250,10 +255,10 @@ function (n::linearNeuron)(kfn::T) where T<:knowledgeFn
|
||||
end
|
||||
|
||||
# there is a difference from alif formula
|
||||
n.phi = (n.gammaPd / n.v_th) * max(0, 1 - (n.v_t1 - n.v_th) / n.v_th)
|
||||
n.phi = (n.gammaPd / n.v_th) * max(0, 1 - (n.v_t1 - n.v_th) / n.v_th)
|
||||
n.decayedEpsilonRec = n.alpha * n.epsilonRec
|
||||
n.epsilonRec = n.decayedEpsilonRec + n.z_i_t
|
||||
end
|
||||
n.epsilonRec = n.decayedEpsilonRec + n.z_i_t
|
||||
end
|
||||
end
|
||||
|
||||
#------------------------------------------------------------------------------------------------100
|
||||
@@ -267,7 +272,8 @@ function (n::integrateNeuron)(kfn::knowledgeFn)
|
||||
n.z_i_t = getindex(kfn.firedNeurons_t0, n.subscriptionList)
|
||||
n.z_i_t_commulative += n.z_i_t
|
||||
|
||||
n.recSignal = sum(n.wRec .* n.z_i_t) # signal from other neuron that this neuron subscribed
|
||||
n.recSignal = sum(n.wRec .* n.z_i_t) # signal from other neuron that this neuron
|
||||
# computeAlpha!(n)
|
||||
n.alpha_v_t = n.alpha * n.v_t
|
||||
if n.recSignal <= 0
|
||||
n.v_t1 = n.alpha_v_t
|
||||
|
||||
Reference in New Issue
Block a user