time-based learning method based on new error formula
This commit is contained in:
18
src/types.jl
18
src/types.jl
@@ -325,7 +325,8 @@ Base.@kwdef mutable struct lif_neuron <: compute_neuron
|
||||
# during v_t1 calculation hence I need a variable to hold z_t1 so that I'm not replacing z_t
|
||||
z_t1::Bool = false # neuron postsynaptic firing at current timestep (after neuron's calculation)
|
||||
z_i_t::Union{Array{Bool},Nothing} = nothing # neuron presynaptic firing at current timestep (which is other neuron postsynaptic firing of previous timestep)
|
||||
# Bn_wout_decay::Union{Float64,Nothing} = 0.01 # use to balance Bn and w_out
|
||||
synapticStrength::Union{Array{Float64},Nothing} = nothing
|
||||
synapticStrengthLimit::Union{NamedTuple,Nothing} = (lowerlimit=(0=>0), upperlimit=(10=>10))
|
||||
|
||||
gammaPd::Union{Float64,Nothing} = 0.3 # γ_pd, discount factor, value from paper
|
||||
alpha::Union{Float64,Nothing} = nothing # α, neuron membrane potential decay factor
|
||||
@@ -334,7 +335,6 @@ Base.@kwdef mutable struct lif_neuron <: compute_neuron
|
||||
decayedEpsilonRec::Union{Array{Float64},Nothing} = nothing # α * epsilonRec
|
||||
eRec::Union{Array{Float64},Nothing} = nothing # eligibility trace for neuron spike
|
||||
delta::Union{Float64,Nothing} = 1.0 # δ, discreate timestep size in millisecond
|
||||
lastFiringTime::Union{Float64,Nothing} = 0.0 # the last time neuron fires, use to calculate exponantial decay of v_t1
|
||||
refractoryDuration::Union{Float64,Nothing} = 3 # neuron's refratory period in millisecond
|
||||
# refractory_state_active::Union{Bool,Nothing} = false # if true, neuron is in refractory state and cannot process new information
|
||||
refractoryCounter::Integer = 0
|
||||
@@ -418,7 +418,8 @@ Base.@kwdef mutable struct alif_neuron <: compute_neuron
|
||||
# during v_t1 calculation hence I need a variable to hold z_t1 so that I'm not replacing z_t
|
||||
z_t1::Bool = false # neuron postsynaptic firing at current timestep (after neuron's calculation)
|
||||
z_i_t::Union{Array{Bool},Nothing} = nothing # neuron presynaptic firing at current timestep (which is other neuron postsynaptic firing of previous timestep)
|
||||
# Bn_wout_decay::Union{Float64,Nothing} = 0.01 # use to balance Bn and w_out
|
||||
synapticStrength::Union{Array{Float64},Nothing} = nothing
|
||||
synapticStrengthLimit::Union{NamedTuple,Nothing} = (lowerlimit=(-5=>0), upperlimit=(5=>5))
|
||||
|
||||
alpha::Union{Float64,Nothing} = nothing # α, neuron membrane potential decay factor
|
||||
delta::Union{Float64,Nothing} = 1.0 # δ, discreate timestep size in millisecond
|
||||
@@ -430,7 +431,6 @@ Base.@kwdef mutable struct alif_neuron <: compute_neuron
|
||||
eRec::Union{Array{Float64},Nothing} = nothing # neuron's eligibility trace
|
||||
eta::Union{Float64,Nothing} = 0.01 # eta, learning rate
|
||||
gammaPd::Union{Float64,Nothing} = 0.3 # γ_pd, discount factor, value from paper
|
||||
lastFiringTime::Union{Float64,Nothing} = 0.0 # the last time neuron fires, use to calculate exponantial decay of v_t1
|
||||
phi::Union{Float64,Nothing} = nothing # ϕ, psuedo derivative
|
||||
refractoryDuration::Union{Float64,Nothing} = 3 # neuron's refractory period in millisecond
|
||||
# refractory_state_active::Union{Bool,Nothing} = false # if true, neuron is in refractory state and cannot process new information
|
||||
@@ -528,6 +528,8 @@ Base.@kwdef mutable struct linear_neuron <: output_neuron
|
||||
# neuron presynaptic firing at current timestep (which is other neuron postsynaptic firing of
|
||||
# previous timestep)
|
||||
z_i_t::Union{Array{Bool},Nothing} = nothing
|
||||
synapticStrength::Union{Array{Float64},Nothing} = nothing
|
||||
synapticStrengthLimit::Union{NamedTuple,Nothing} = (lowerlimit=(-5=>0), upperlimit=(5=>5))
|
||||
|
||||
gammaPd::Union{Float64,Nothing} = 0.3 # γ_pd, discount factor, value from paper
|
||||
alpha::Union{Float64,Nothing} = nothing # α, neuron membrane potential decay factor
|
||||
@@ -536,7 +538,6 @@ Base.@kwdef mutable struct linear_neuron <: output_neuron
|
||||
decayedEpsilonRec::Union{Array{Float64},Nothing} = nothing # α * epsilonRec
|
||||
eRec::Union{Array{Float64},Nothing} = nothing # eligibility trace for neuron spike
|
||||
delta::Union{Float64,Nothing} = 1.0 # δ, discreate timestep size in millisecond
|
||||
lastFiringTime::Union{Float64,Nothing} = 0.0 # the last time neuron fires, use to calculate exponantial decay of v_t1
|
||||
refractoryDuration::Union{Float64,Nothing} = 3 # neuron's refratory period in millisecond
|
||||
refractoryCounter::Integer = 0
|
||||
tau_out::Union{Float64,Nothing} = nothing # τ_out, membrane time constant in millisecond
|
||||
@@ -629,11 +630,11 @@ function init_neuron!(id::Int64, n::lif_neuron, n_params::Dict, kfnParams::Dict)
|
||||
|
||||
# prevent subscription to itself by removing this neuron id
|
||||
filter!(x -> x != n.id, n.subscriptionList)
|
||||
n.synapticStrength = normalize!(rand(length(n.subscriptionList)), 1)
|
||||
|
||||
n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
n.w_rec = Random.rand(length(n.subscriptionList))
|
||||
n.wRecChange = zeros(length(n.subscriptionList))
|
||||
# n.reg_voltage_b = zeros(length(n.subscriptionList))
|
||||
n.alpha = calculate_α(n)
|
||||
end
|
||||
|
||||
@@ -648,6 +649,7 @@ function init_neuron!(id::Int64, n::alif_neuron, n_params::Dict,
|
||||
|
||||
# prevent subscription to itself by removing this neuron id
|
||||
filter!(x -> x != n.id, n.subscriptionList)
|
||||
n.synapticStrength = normalize!(rand(length(n.subscriptionList)), 1)
|
||||
|
||||
n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
n.w_rec = Random.rand(length(n.subscriptionList))
|
||||
@@ -660,7 +662,7 @@ function init_neuron!(id::Int64, n::alif_neuron, n_params::Dict,
|
||||
n.epsilonRecA = zeros(length(n.subscriptionList))
|
||||
end
|
||||
|
||||
#WORKING
|
||||
|
||||
function init_neuron!(id::Int64, n::linear_neuron, n_params::Dict, kfnParams::Dict)
|
||||
n.id = id
|
||||
n.knowledgeFnName = kfnParams[:knowledgeFnName]
|
||||
@@ -669,7 +671,7 @@ function init_neuron!(id::Int64, n::linear_neuron, n_params::Dict, kfnParams::Di
|
||||
subscription_numbers = Int(floor(n_params[:synaptic_connection_number] *
|
||||
kfnParams[:total_compute_neuron] / 100.0))
|
||||
n.subscriptionList = [pop!(subscription_options) for i = 1:subscription_numbers]
|
||||
|
||||
n.synapticStrength = normalize!(rand(length(n.subscriptionList)), 1)
|
||||
n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
n.w_rec = Random.rand(length(n.subscriptionList))
|
||||
n.wRecChange = zeros(length(n.subscriptionList))
|
||||
|
||||
Reference in New Issue
Block a user