add normalizePeak!
This commit is contained in:
@@ -86,6 +86,9 @@ function learn!(kfn::kfn_1, correctAnswer::AbstractVector)
|
||||
nonFlipedSign = isequal.(n.subExInType, wSign) # 1 not fliped, 0 fliped
|
||||
LinearAlgebra.normalize!(n.wRec, 1)
|
||||
n.wRec .*= nonFlipedSign # set weight that fliped sign to 0 for random new connection
|
||||
# normalize wRec peak to prevent input signal overwhelming neuron
|
||||
normalizePeak!(n.wRec, 2)
|
||||
|
||||
|
||||
synapticConnStrength!(n)
|
||||
#TODO neuroplasticity
|
||||
|
||||
@@ -4,7 +4,7 @@ using Flux.Optimise: apply!
|
||||
export calculate_α, calculate_ρ, calculate_k, timestep_forward!, init_neuron, no_negative!,
|
||||
precision, calculate_w_change!, store_knowledgefn_error!, interneurons_adjustment!,
|
||||
reset_z_t!, resetLearningParams!, reset_learning_history_params!, reset_epsilonRec!,
|
||||
reset_epsilonRecA!, synapticConnStrength!,
|
||||
reset_epsilonRecA!, synapticConnStrength!, normalizePeak!,
|
||||
firing_rate_error!, firing_rate_regulator!, update_Bn!, cal_firing_reg!,
|
||||
neuroplasticity!, shakeup!, reset_learning_no_wchange!, adjust_internal_learning_rate!,
|
||||
gradient_withloss
|
||||
@@ -317,7 +317,18 @@ function neuroplasticity!(n::compute_neuron, firedNeurons::Vector)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
""" normalize a part of a vector centering at a vector's maximum value along with nearby value
|
||||
within its radius. radius must be odd number
|
||||
"""
|
||||
function normalizePeak!(v::Vector, radius::Integer=2)
|
||||
peak = findall(isequal.(n.wRec, maximum(n.wRec)))[1]
|
||||
upindex = peak - radius
|
||||
upindex = upindex < 1 ? 1 : upindex
|
||||
downindex = peak + radius
|
||||
downindex = downindex > length(v) ? length(v) : downindex
|
||||
subvector = view(v, upindex:downindex)
|
||||
normalize!(subvector, 1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -630,7 +630,7 @@ function init_neuron!(id::Int64, n::lif_neuron, n_params::Dict, kfnParams::Dict)
|
||||
n.synapticStrength = rand(-5:0.1:-3, length(n.subscriptionList))
|
||||
|
||||
n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
n.wRec = LinearAlgebra.normalize!(rand(length(n.subscriptionList)), 1)
|
||||
n.wRec = rand(length(n.subscriptionList))
|
||||
n.wRecChange = zeros(length(n.subscriptionList))
|
||||
n.alpha = calculate_α(n)
|
||||
end
|
||||
@@ -649,7 +649,7 @@ function init_neuron!(id::Int64, n::alif_neuron, n_params::Dict,
|
||||
n.synapticStrength = rand(-5:0.1:-3, length(n.subscriptionList))
|
||||
|
||||
n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
n.wRec = LinearAlgebra.normalize!(rand(length(n.subscriptionList)), 1)
|
||||
n.wRec = rand(length(n.subscriptionList))
|
||||
n.wRecChange = zeros(length(n.subscriptionList))
|
||||
|
||||
# the more time has passed from the last time neuron was activated, the more
|
||||
@@ -671,7 +671,7 @@ function init_neuron!(id::Int64, n::linear_neuron, n_params::Dict, kfnParams::Di
|
||||
n.synapticStrength = rand(-5:0.1:-3, length(n.subscriptionList))
|
||||
|
||||
n.epsilonRec = zeros(length(n.subscriptionList))
|
||||
n.wRec = LinearAlgebra.normalize!(rand(length(n.subscriptionList)), 1)
|
||||
n.wRec = rand(length(n.subscriptionList))
|
||||
n.wRecChange = zeros(length(n.subscriptionList))
|
||||
n.alpha = calculate_k(n)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user