refractoring
This commit is contained in:
@@ -15,7 +15,7 @@ using ..types
|
||||
|
||||
#------------------------------------------------------------------------------------------------100
|
||||
|
||||
function timestep_forward!(x::passthrough_neuron)
|
||||
function timestep_forward!(x::passthroughNeuron)
|
||||
x.z_t = x.z_t1
|
||||
end
|
||||
|
||||
@@ -34,30 +34,30 @@ reset_v_t!(n::neuron) = n.v_t = n.vRest
|
||||
reset_z_t!(n::computeNeuron) = n.z_t = false
|
||||
reset_epsilonRec!(n::computeNeuron) = n.epsilonRec = n.epsilonRec * 0.0
|
||||
reset_epsilonRec!(n::outputNeuron) = n.epsilonRec = n.epsilonRec * 0.0
|
||||
reset_epsilonRecA!(n::alif_neuron) = n.epsilonRecA = n.epsilonRecA * 0.0
|
||||
reset_epsilonRecA!(n::alifNeuron) = n.epsilonRecA = n.epsilonRecA * 0.0
|
||||
reset_epsilon_in!(n::computeNeuron) = n.epsilon_in = isnothing(n.epsilon_in) ? nothing : n.epsilon_in * 0.0
|
||||
reset_error!(n::Union{computeNeuron, linear_neuron}) = n.error = nothing
|
||||
reset_error!(n::Union{computeNeuron, linearNeuron}) = n.error = nothing
|
||||
reset_w_in_change!(n::computeNeuron) = n.w_in_change = isnothing(n.w_in_change) ? nothing : n.w_in_change * 0.0
|
||||
reset_wRecChange!(n::Union{computeNeuron, outputNeuron}) = n.wRecChange = n.wRecChange * 0.0
|
||||
reset_a!(n::alif_neuron) = n.a = n.a * 0.0
|
||||
reset_a!(n::alifNeuron) = n.a = n.a * 0.0
|
||||
reset_reg_voltage_a!(n::computeNeuron) = n.reg_voltage_a = n.reg_voltage_a * 0.0
|
||||
reset_reg_voltage_b!(n::computeNeuron) = n.reg_voltage_b = n.reg_voltage_b * 0.0
|
||||
reset_reg_voltage_error!(n::computeNeuron) = n.reg_voltage_error = n.reg_voltage_error * 0.0
|
||||
reset_firing_counter!(n::computeNeuron) = n.firingCounter = n.firingCounter * 0.0
|
||||
reset_firing_diff!(n::Union{computeNeuron, linear_neuron}) = n.firingDiff = n.firingDiff * 0.0
|
||||
reset_refractoryCounter!(n::Union{computeNeuron, linear_neuron}) = n.refractoryCounter = n.refractoryCounter * 0.0
|
||||
reset_firing_counter!(n::Union{computeNeuron, outputNeuron}) = n.firingCounter = n.firingCounter * 0.0
|
||||
reset_firing_diff!(n::Union{computeNeuron, linearNeuron}) = n.firingDiff = n.firingDiff * 0.0
|
||||
reset_refractoryCounter!(n::Union{computeNeuron, outputNeuron}) = n.refractoryCounter = n.refractoryCounter * 0.0
|
||||
|
||||
# reset function for output neuron
|
||||
reset_epsilon_j!(n::linear_neuron) = n.epsilon_j = n.epsilon_j * 0.0
|
||||
reset_out_t!(n::linear_neuron) = n.out_t = n.out_t * 0.0
|
||||
reset_w_out_change!(n::linear_neuron) = n.w_out_change = n.w_out_change * 0.0
|
||||
reset_b_change!(n::linear_neuron) = n.b_change = n.b_change * 0.0
|
||||
reset_epsilon_j!(n::linearNeuron) = n.epsilon_j = n.epsilon_j * 0.0
|
||||
reset_out_t!(n::linearNeuron) = n.out_t = n.out_t * 0.0
|
||||
reset_w_out_change!(n::linearNeuron) = n.w_out_change = n.w_out_change * 0.0
|
||||
reset_b_change!(n::linearNeuron) = n.b_change = n.b_change * 0.0
|
||||
|
||||
|
||||
""" Reset a part of learning-related params that used to collect learning history during learning
|
||||
session
|
||||
"""
|
||||
# function reset_learning_no_wchange!(n::lif_neuron)
|
||||
# function reset_learning_no_wchange!(n::lifNeuron)
|
||||
# reset_epsilonRec!(n)
|
||||
# # reset_v_t!(n)
|
||||
# # reset_z_t!(n)
|
||||
@@ -73,7 +73,7 @@ reset_b_change!(n::linear_neuron) = n.b_change = n.b_change * 0.0
|
||||
# # # it will stay in refractory state forever
|
||||
# # reset_refractory_state_active!(n)
|
||||
# end
|
||||
# function reset_learning_no_wchange!(n::Union{alif_neuron, elif_neuron})
|
||||
# function reset_learning_no_wchange!(n::Union{alifNeuron, elif_neuron})
|
||||
# reset_epsilonRec!(n)
|
||||
# reset_epsilonRecA!(n)
|
||||
# reset_v_t!(n)
|
||||
@@ -91,7 +91,7 @@ reset_b_change!(n::linear_neuron) = n.b_change = n.b_change * 0.0
|
||||
# # it will stay in refractory state forever
|
||||
# reset_refractory_state_active!(n)
|
||||
# end
|
||||
# function reset_learning_no_wchange!(n::linear_neuron)
|
||||
# function reset_learning_no_wchange!(n::linearNeuron)
|
||||
# reset_epsilon_j!(n)
|
||||
# reset_out_t!(n)
|
||||
# reset_error!(n)
|
||||
@@ -99,7 +99,7 @@ reset_b_change!(n::linear_neuron) = n.b_change = n.b_change * 0.0
|
||||
|
||||
""" Reset all learning-related params at the END of learning session
|
||||
"""
|
||||
function resetLearningParams!(n::lif_neuron)
|
||||
function resetLearningParams!(n::lifNeuron)
|
||||
reset_epsilonRec!(n)
|
||||
reset_wRecChange!(n)
|
||||
# reset_v_t!(n)
|
||||
@@ -111,7 +111,7 @@ function resetLearningParams!(n::lif_neuron)
|
||||
# refractory state, it will stay in refractory state forever
|
||||
reset_refractoryCounter!(n)
|
||||
end
|
||||
function resetLearningParams!(n::alif_neuron)
|
||||
function resetLearningParams!(n::alifNeuron)
|
||||
reset_epsilonRec!(n)
|
||||
reset_epsilonRecA!(n)
|
||||
reset_wRecChange!(n)
|
||||
@@ -126,14 +126,14 @@ function resetLearningParams!(n::alif_neuron)
|
||||
reset_refractoryCounter!(n)
|
||||
end
|
||||
|
||||
# function reset_learning_no_wchange!(n::passthrough_neuron)
|
||||
# function reset_learning_no_wchange!(n::passthroughNeuron)
|
||||
# end
|
||||
|
||||
function resetLearningParams!(n::passthrough_neuron)
|
||||
function resetLearningParams!(n::passthroughNeuron)
|
||||
# skip
|
||||
end
|
||||
|
||||
function resetLearningParams!(n::linear_neuron)
|
||||
function resetLearningParams!(n::linearNeuron)
|
||||
reset_epsilonRec!(n)
|
||||
reset_wRecChange!(n)
|
||||
reset_v_t!(n)
|
||||
@@ -196,7 +196,7 @@ end
|
||||
|
||||
""" Regulates membrane potential to stay under v_th, output is weight change
|
||||
"""
|
||||
function cal_v_reg!(n::lif_neuron)
|
||||
function cal_v_reg!(n::lifNeuron)
|
||||
# retified linear function
|
||||
component_a1 = n.v_t1 - n.v_th < 0 ? 0 : (n.v_t1 - n.v_th)^2
|
||||
component_a2 = -n.v_t1 - n.v_th < 0 ? 0 : (-n.v_t1 - n.v_th)^2
|
||||
@@ -207,7 +207,7 @@ function cal_v_reg!(n::lif_neuron)
|
||||
n.reg_voltage_b = n.reg_voltage_b + (component_b * n.epsilonRec)
|
||||
end
|
||||
|
||||
function cal_v_reg!(n::alif_neuron)
|
||||
function cal_v_reg!(n::alifNeuron)
|
||||
# retified linear function
|
||||
component_a1 = n.v_t1 - n.av_th < 0 ? 0 : (n.v_t1 - n.av_th)^2
|
||||
component_a2 = -n.v_t1 - n.av_th < 0 ? 0 : (-n.v_t1 - n.av_th)^2
|
||||
|
||||
Reference in New Issue
Block a user