output neuron connect to random multiple compute neurons

This commit is contained in:
2023-05-15 14:13:45 +07:00
parent 68c8a3597d
commit 114161ba69
5 changed files with 94 additions and 75 deletions

View File

@@ -24,17 +24,13 @@ function timestep_forward!(x::compute_neuron)
x.v_t = x.v_t1
end
function timestep_forward!(x::linear_neuron)
x.out_t = x.out_t1
end
no_negative!(x) = x < 0.0 ? 0.0 : x
precision(x::Array{<:Array}) = ( std(mean.(x)) / mean(mean.(x)) ) * 100
# reset functions for LIF/ALIF neuron
reset_last_firing_time!(n::compute_neuron) = n.lastFiringTime = 0.0
reset_refractory_state_active!(n::compute_neuron) = n.refractory_state_active = false
reset_v_t!(n::compute_neuron) = n.v_t = n.v_t_default
reset_v_t!(n::neuron) = n.v_t = n.vRest
reset_z_t!(n::compute_neuron) = n.z_t = false
reset_epsilon_rec!(n::compute_neuron) = n.epsilonRec = n.epsilonRec * 0.0
reset_epsilon_rec_a!(n::alif_neuron) = n.epsilonRecA = n.epsilonRecA * 0.0
@@ -48,6 +44,7 @@ reset_reg_voltage_b!(n::compute_neuron) = n.reg_voltage_b = n.reg_voltage_b * 0.
reset_reg_voltage_error!(n::compute_neuron) = n.reg_voltage_error = n.reg_voltage_error * 0.0
reset_firing_counter!(n::compute_neuron) = n.firingCounter = n.firingCounter * 0.0
reset_firing_diff!(n::Union{compute_neuron, linear_neuron}) = n.firingDiff = n.firingDiff * 0.0
reset_refractoryCounter!(n::Union{compute_neuron, linear_neuron}) = 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
@@ -106,17 +103,14 @@ function reset_learning_params!(n::lif_neuron)
reset_w_rec_change!(n)
# reset_v_t!(n)
# reset_z_t!(n)
# reset_reg_voltage_a!(n)
# reset_reg_voltage_b!(n)
# reset_reg_voltage_error!(n)
reset_firing_counter!(n)
reset_firing_diff!(n)
reset_previous_error!(n)
reset_error!(n)
# # reset refractory state at the end of episode. Otherwise once neuron goes into refractory state,
# # it will stay in refractory state forever
# reset_refractory_state_active!(n)
# reset refractory state at the start/end of episode. Otherwise once neuron goes into
# refractory state, it will stay in refractory state forever
reset_refractoryCounter!(n)
end
function reset_learning_params!(n::alif_neuron)
reset_epsilon_rec!(n)
@@ -125,17 +119,14 @@ function reset_learning_params!(n::alif_neuron)
# reset_v_t!(n)
# reset_z_t!(n)
# reset_a!(n)
# reset_reg_voltage_a!(n)
# reset_reg_voltage_b!(n)
# reset_reg_voltage_error!(n)
reset_firing_counter!(n)
reset_firing_diff!(n)
reset_previous_error!(n)
reset_error!(n)
# # reset refractory state at the end of episode. Otherwise once neuron goes into refractory state,
# # it will stay in refractory state forever
# reset_refractory_state_active!(n)
# reset refractory state at the start/end of episode. Otherwise once neuron goes into
# refractory state, it will stay in refractory state forever
reset_refractoryCounter!(n)
end
# function reset_learning_no_wchange!(n::passthrough_neuron)
@@ -144,7 +135,20 @@ end
function reset_learning_params!(n::passthrough_neuron)
# skip
end
#WORKING
function reset_learning_params!(n::linear_neuron)
reset_epsilon_rec!(n)
reset_w_rec_change!(n)
reset_v_t!(n)
reset_firing_counter!(n)
reset_firing_diff!(n)
reset_previous_error!(n)
reset_error!(n)
# reset refractory state at the start/end of episode. Otherwise once neuron goes into
# refractory state, it will stay in refractory state forever
reset_refractoryCounter!(n)
end
#------------------------------------------------------------------------------------------------100
function store_knowledgefn_error!(kfn::knowledgeFn)