reset_epsilonRec after ΔwRecChange is calculated
This commit is contained in:
28
src/types.jl
28
src/types.jl
@@ -34,7 +34,7 @@ Base.@kwdef mutable struct model <: Ironpen
|
||||
"learning" = neuron will accumulate epsilon_j, compute Δw_rec_change each time
|
||||
correct answer is available then merge Δw_rec_change into wRecChange then
|
||||
reset epsilon_j.
|
||||
"reflect" = neuron will merge wRecChange into w_rec then reset wRecChange. """
|
||||
"reflect" = neuron will merge wRecChange into wRec then reset wRecChange. """
|
||||
learningStage::String = "inference"
|
||||
|
||||
softreset::Bool = false
|
||||
@@ -102,7 +102,7 @@ Base.@kwdef mutable struct kfn_1 <: knowledgeFn
|
||||
"learning" = neuron will accumulate epsilon_j, compute Δw_rec_change each time
|
||||
correct answer is available then merge Δw_rec_change into wRecChange then
|
||||
reset epsilon_j.
|
||||
"reflect" = neuron will merge wRecChange into w_rec then reset wRecChange. """
|
||||
"reflect" = neuron will merge wRecChange into wRec then reset wRecChange. """
|
||||
learningStage::String = "inference"
|
||||
|
||||
error::Union{Float64,Nothing} = nothing
|
||||
@@ -312,7 +312,7 @@ Base.@kwdef mutable struct lif_neuron <: compute_neuron
|
||||
subscriptionList::Union{Array{Int64},Nothing} = nothing # list of other neuron that this neuron synapse subscribed to
|
||||
subExInType::Array{Int64} = Vector{Int64}() # store ExIn type of subscribed neurons
|
||||
timeStep::Number = 0.0 # current time
|
||||
w_rec::Union{Array{Float64},Nothing} = nothing # synaptic weight (for receiving signal from other neuron)
|
||||
wRec::Union{Array{Float64},Nothing} = nothing # synaptic weight (for receiving signal from other neuron)
|
||||
v_t::Float64 = rand() # vᵗ, postsynaptic neuron membrane potential of previous timestep
|
||||
v_t1::Float64 = 0.0 # vᵗ⁺¹, postsynaptic neuron membrane potential at current timestep
|
||||
v_t_default::Union{Float64,Nothing} = 0.0 # default membrane potential voltage
|
||||
@@ -340,7 +340,7 @@ Base.@kwdef mutable struct lif_neuron <: compute_neuron
|
||||
refractoryCounter::Integer = 0
|
||||
tau_m::Union{Float64,Nothing} = nothing # τ_m, membrane time constant in millisecond
|
||||
eta::Union{Float64,Nothing} = 0.01 # η, learning rate
|
||||
wRecChange::Union{Array{Float64},Nothing} = nothing # Δw_rec, cumulated w_rec change
|
||||
wRecChange::Union{Array{Float64},Nothing} = nothing # Δw_rec, cumulated wRec change
|
||||
recSignal::Union{Float64,Nothing} = nothing # incoming recurrent signal
|
||||
alpha_v_t::Union{Float64,Nothing} = nothing # alpha * v_t
|
||||
error::Union{Float64,Nothing} = nothing # local neuron error
|
||||
@@ -356,7 +356,7 @@ Base.@kwdef mutable struct lif_neuron <: compute_neuron
|
||||
"learning" = neuron will accumulate epsilon_j, compute Δw_rec_change each time
|
||||
correct answer is available then merge Δw_rec_change into wRecChange then
|
||||
reset epsilon_j.
|
||||
"reflect" = neuron will merge wRecChange into w_rec then reset wRecChange. """
|
||||
"reflect" = neuron will merge wRecChange into wRec then reset wRecChange. """
|
||||
learningStage::String = "inference"
|
||||
end
|
||||
|
||||
@@ -405,7 +405,7 @@ Base.@kwdef mutable struct alif_neuron <: compute_neuron
|
||||
subscriptionList::Union{Array{Int64},Nothing} = nothing # list of other neuron that this neuron synapse subscribed to
|
||||
subExInType::Array{Int64} = Vector{Int64}() # store ExIn type of subscribed neurons
|
||||
timeStep::Union{Number,Nothing} = nothing # current time
|
||||
w_rec::Union{Array{Float64},Nothing} = nothing # synaptic weight (for receiving signal from other neuron)
|
||||
wRec::Union{Array{Float64},Nothing} = nothing # synaptic weight (for receiving signal from other neuron)
|
||||
v_t::Float64 = rand() # vᵗ, postsynaptic neuron membrane potential of previous timestep
|
||||
v_t1::Float64 = 0.0 # vᵗ⁺¹, postsynaptic neuron membrane potential at current timestep
|
||||
v_t_default::Union{Float64,Nothing} = 0.0
|
||||
@@ -436,7 +436,7 @@ Base.@kwdef mutable struct alif_neuron <: compute_neuron
|
||||
# refractory_state_active::Union{Bool,Nothing} = false # if true, neuron is in refractory state and cannot process new information
|
||||
refractoryCounter::Integer = 0
|
||||
tau_m::Union{Float64,Nothing} = nothing # τ_m, membrane time constant in millisecond
|
||||
wRecChange::Union{Array{Float64},Nothing} = nothing # Δw_rec, cumulated w_rec change
|
||||
wRecChange::Union{Array{Float64},Nothing} = nothing # Δw_rec, cumulated wRec change
|
||||
recSignal::Union{Float64,Nothing} = nothing # incoming recurrent signal
|
||||
alpha_v_t::Union{Float64,Nothing} = nothing # alpha * v_t
|
||||
error::Union{Float64,Nothing} = nothing # local neuron error
|
||||
@@ -458,7 +458,7 @@ Base.@kwdef mutable struct alif_neuron <: compute_neuron
|
||||
"learning" = neuron will accumulate epsilon_j, compute Δw_rec_change each time
|
||||
correct answer is available then merge Δw_rec_change into wRecChange then
|
||||
reset epsilon_j.
|
||||
"reflect" = neuron will merge wRecChange into w_rec then reset wRecChange. """
|
||||
"reflect" = neuron will merge wRecChange into wRec then reset wRecChange. """
|
||||
learningStage::String = "inference"
|
||||
|
||||
end
|
||||
@@ -513,7 +513,7 @@ Base.@kwdef mutable struct linear_neuron <: output_neuron
|
||||
timeStep::Union{Number,Nothing} = nothing # current time
|
||||
|
||||
subExInType::Array{Int64} = Vector{Int64}() # store ExIn type of subscribed neurons
|
||||
w_rec::Union{Array{Float64},Nothing} = nothing # synaptic weight (for receiving signal from other neuron)
|
||||
wRec::Union{Array{Float64},Nothing} = nothing # synaptic weight (for receiving signal from other neuron)
|
||||
v_t::Float64 = 0.0 # vᵗ, postsynaptic neuron membrane potential of previous timestep
|
||||
v_t1::Float64 = 0.0 # vᵗ⁺¹, postsynaptic neuron membrane potential at current timestep
|
||||
v_t_default::Union{Float64,Nothing} = 0.0 # default membrane potential voltage
|
||||
@@ -542,7 +542,7 @@ Base.@kwdef mutable struct linear_neuron <: output_neuron
|
||||
refractoryCounter::Integer = 0
|
||||
tau_out::Union{Float64,Nothing} = nothing # τ_out, membrane time constant in millisecond
|
||||
eta::Union{Float64,Nothing} = 0.01 # η, learning rate
|
||||
wRecChange::Union{Array{Float64},Nothing} = nothing # Δw_rec, cumulated w_rec change
|
||||
wRecChange::Union{Array{Float64},Nothing} = nothing # Δw_rec, cumulated wRec change
|
||||
recSignal::Union{Float64,Nothing} = nothing # incoming recurrent signal
|
||||
alpha_v_t::Union{Float64,Nothing} = nothing # alpha * v_t
|
||||
error::Union{Float64,Nothing} = nothing # local neuron error
|
||||
@@ -614,7 +614,7 @@ end
|
||||
# end
|
||||
# filter!(x -> x != n.id, n.subscriptionList)
|
||||
# n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
# n.w_rec = Random.rand(length(n.subscriptionList))
|
||||
# n.wRec = Random.rand(length(n.subscriptionList))
|
||||
# n.wRecChange = zeros(length(n.subscriptionList))
|
||||
# n.reg_voltage_b = zeros(length(n.subscriptionList))
|
||||
# n.alpha = calculate_α(n)
|
||||
@@ -633,7 +633,7 @@ function init_neuron!(id::Int64, n::lif_neuron, n_params::Dict, kfnParams::Dict)
|
||||
n.synapticStrength = normalize!(rand(length(n.subscriptionList)), 1)
|
||||
|
||||
n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
n.w_rec = Random.rand(length(n.subscriptionList))
|
||||
n.wRec = Random.rand(length(n.subscriptionList))
|
||||
n.wRecChange = zeros(length(n.subscriptionList))
|
||||
n.alpha = calculate_α(n)
|
||||
end
|
||||
@@ -652,7 +652,7 @@ function init_neuron!(id::Int64, n::alif_neuron, n_params::Dict,
|
||||
n.synapticStrength = normalize!(rand(length(n.subscriptionList)), 1)
|
||||
|
||||
n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
n.w_rec = Random.rand(length(n.subscriptionList))
|
||||
n.wRec = Random.rand(length(n.subscriptionList))
|
||||
n.wRecChange = zeros(length(n.subscriptionList))
|
||||
|
||||
# the more time has passed from the last time neuron was activated, the more
|
||||
@@ -673,7 +673,7 @@ function init_neuron!(id::Int64, n::linear_neuron, n_params::Dict, kfnParams::Di
|
||||
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.wRec = Random.rand(length(n.subscriptionList))
|
||||
n.wRecChange = zeros(length(n.subscriptionList))
|
||||
n.alpha = calculate_k(n)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user