implement start learning
This commit is contained in:
42
src/types.jl
42
src/types.jl
@@ -106,7 +106,6 @@ Base.@kwdef mutable struct kfn_1 <: knowledgeFn
|
||||
learningStage::String = "inference"
|
||||
|
||||
error::Union{Float64,Nothing} = nothing
|
||||
outputError::Union{Array,Nothing} = Vector{AbstractFloat}()
|
||||
softreset::Bool = false
|
||||
|
||||
firedNeurons::Array{Int64} = Vector{Int64}() # store unique id of firing neurons to be used when random neuron connection
|
||||
@@ -331,7 +330,7 @@ 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
|
||||
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
|
||||
@@ -340,7 +339,6 @@ Base.@kwdef mutable struct lif_neuron <: compute_neuron
|
||||
wRecChange::Union{Array{Float64},Nothing} = nothing # Δw_rec, cumulated w_rec change
|
||||
recSignal::Union{Float64,Nothing} = nothing # incoming recurrent signal
|
||||
alpha_v_t::Union{Float64,Nothing} = nothing # alpha * v_t
|
||||
voltageDropPercentage::Union{Float64,Nothing} = 1.0 # voltage drop as a percentage of v_th
|
||||
error::Union{Float64,Nothing} = nothing # local neuron error
|
||||
optimiser::Union{Any,Nothing} = load_optimiser("AdaBelief") # Flux optimizer
|
||||
|
||||
@@ -428,7 +426,7 @@ 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
|
||||
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
|
||||
@@ -437,7 +435,6 @@ Base.@kwdef mutable struct alif_neuron <: compute_neuron
|
||||
wRecChange::Union{Array{Float64},Nothing} = nothing # Δw_rec, cumulated w_rec change
|
||||
recSignal::Union{Float64,Nothing} = nothing # incoming recurrent signal
|
||||
alpha_v_t::Union{Float64,Nothing} = nothing # alpha * v_t
|
||||
voltageDropPercentage::Union{Float64,Nothing} = 1.0 # voltage drop as a percentage of v_th
|
||||
error::Union{Float64,Nothing} = nothing # local neuron error
|
||||
optimiser::Union{Any,Nothing} = load_optimiser("AdaBelief") # Flux optimizer
|
||||
|
||||
@@ -510,9 +507,42 @@ Base.@kwdef mutable struct linear_neuron <: output_neuron
|
||||
knowledgeFnName::Union{String,Nothing} = nothing # knowledgeFn that this neuron belongs to
|
||||
subscriptionList::Union{Array{Int64},Nothing} = nothing # list of other neuron that this neuron synapse subscribed to
|
||||
timeStep::Union{Number,Nothing} = nothing # current time
|
||||
delta::Union{Float64,Nothing} = 1.0 # δ, discreate timestep size in millisecond
|
||||
out_t::Bool = false # output of linear neuron BEFORE forward()
|
||||
out_t1::Bool = false # output of linear neuron AFTER forward()
|
||||
#WORKING
|
||||
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)
|
||||
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
|
||||
v_th::Float64 = 1.0 # vᵗʰ, neuron firing threshold
|
||||
vRest::Float64 = 0.0 # resting potential after neuron fired
|
||||
# zᵗ⁺¹, neuron firing status at time = t+1. I need this because the way I calculate all
|
||||
# neurons forward function at each timestep-by-timestep is to do every neuron
|
||||
# forward calculation. Each neuron requires access to other neuron's firing status
|
||||
# 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)
|
||||
|
||||
# neuron presynaptic firing at current timestep (which is other neuron postsynaptic firing of
|
||||
# previous timestep)
|
||||
z_i_t::Union{Array{Bool},Nothing} = nothing
|
||||
|
||||
gammaPd::Union{Float64,Nothing} = 0.3 # γ_pd, discount factor, value from paper
|
||||
alpha::Union{Float64,Nothing} = nothing # α, neuron membrane potential decay factor
|
||||
phi::Union{Float64,Nothing} = nothing # ϕ, psuedo derivative
|
||||
epsilonRec::Union{Array{Float64},Nothing} = nothing # ϵ_rec, eligibility vector for neuron spike
|
||||
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_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
|
||||
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
|
||||
end
|
||||
|
||||
""" linear neuron outer constructor
|
||||
|
||||
Reference in New Issue
Block a user