synaptic connection strength concept
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
module Ironpen
|
module Ironpen
|
||||||
|
|
||||||
export kfn_1
|
export kfn_1, synapticConnStrength!
|
||||||
|
|
||||||
|
|
||||||
""" Order by dependencies of each file. The 1st included file must not depend on any other
|
""" Order by dependencies of each file. The 1st included file must not depend on any other
|
||||||
@@ -35,7 +35,6 @@ using .interface
|
|||||||
"""
|
"""
|
||||||
Todo:
|
Todo:
|
||||||
[3] verify that model can complete learning cycle with no error
|
[3] verify that model can complete learning cycle with no error
|
||||||
[*1] synaptic connection strength concept. use sigmoid, turn connection offline
|
|
||||||
[2] neuroplasticity() i.e. change connection
|
[2] neuroplasticity() i.e. change connection
|
||||||
[] using RL to control learning signal
|
[] using RL to control learning signal
|
||||||
[] consider using Dates.now() instead of timestamp because time_stamp may overflow
|
[] consider using Dates.now() instead of timestamp because time_stamp may overflow
|
||||||
@@ -57,6 +56,7 @@ using .interface
|
|||||||
(vt*100)/vth as error
|
(vt*100)/vth as error
|
||||||
[DONE] use LinearAlgebra.normalize!(vector, 1) to adjust weight after weight merge
|
[DONE] use LinearAlgebra.normalize!(vector, 1) to adjust weight after weight merge
|
||||||
[DONE] reset_epsilonRec after ΔwRecChange is calculated
|
[DONE] reset_epsilonRec after ΔwRecChange is calculated
|
||||||
|
[DONE] synaptic connection strength concept. use sigmoid, turn connection offline
|
||||||
|
|
||||||
Change from version: v06_36a
|
Change from version: v06_36a
|
||||||
-
|
-
|
||||||
|
|||||||
14
src/learn.jl
14
src/learn.jl
@@ -65,7 +65,7 @@ function learn!(kfn::kfn_1, correctAnswer::AbstractVector)
|
|||||||
outs = [n.z_t1 for n in kfn.outputNeuronsArray]
|
outs = [n.z_t1 for n in kfn.outputNeuronsArray]
|
||||||
for (i, out) in enumerate(outs)
|
for (i, out) in enumerate(outs)
|
||||||
if out != correctAnswer[i] # need to adjust weight
|
if out != correctAnswer[i] # need to adjust weight
|
||||||
kfnError = (kfn.outputNeuronsArray[i].v_th - kfn.outputNeuronsArray[i].v_t) *
|
kfnError = (kfn.outputNeuronsArray[i].v_th - kfn.outputNeuronsArray[i].v_t1) *
|
||||||
100 / kfn.outputNeuronsArray[i].v_th
|
100 / kfn.outputNeuronsArray[i].v_th
|
||||||
|
|
||||||
# Threads.@threads for n in kfn.neuronsArray
|
# Threads.@threads for n in kfn.neuronsArray
|
||||||
@@ -87,15 +87,9 @@ function learn!(kfn::kfn_1, correctAnswer::AbstractVector)
|
|||||||
LinearAlgebra.normalize!(n.wRec, 1)
|
LinearAlgebra.normalize!(n.wRec, 1)
|
||||||
n.wRec .*= nonFlipedSign # set weight that fliped sign to 0 for random new connection
|
n.wRec .*= nonFlipedSign # set weight that fliped sign to 0 for random new connection
|
||||||
|
|
||||||
# Threads.@threads for n in kfn.neuronsArray
|
synapticConnStrength!(n)
|
||||||
for n in kfn.neuronsArray
|
|
||||||
#WORKING synapticConnStrength
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#TODO neuroplasticity
|
#TODO neuroplasticity
|
||||||
end
|
println("")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for n in kfn.outputNeuronsArray # merge wRecChange into wRec
|
for n in kfn.outputNeuronsArray # merge wRecChange into wRec
|
||||||
@@ -105,7 +99,7 @@ function learn!(kfn::kfn_1, correctAnswer::AbstractVector)
|
|||||||
LinearAlgebra.normalize!(n.wRec, 1)
|
LinearAlgebra.normalize!(n.wRec, 1)
|
||||||
n.wRec .*= nonFlipedSign # set weight that fliped sign to 0 for random new connection
|
n.wRec .*= nonFlipedSign # set weight that fliped sign to 0 for random new connection
|
||||||
|
|
||||||
#TODO synapticConnStrength
|
synapticConnStrength!(n)
|
||||||
#TODO neuroplasticity
|
#TODO neuroplasticity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ using Flux.Optimise: apply!
|
|||||||
export calculate_α, calculate_ρ, calculate_k, timestep_forward!, init_neuron, no_negative!,
|
export calculate_α, calculate_ρ, calculate_k, timestep_forward!, init_neuron, no_negative!,
|
||||||
precision, calculate_w_change!, store_knowledgefn_error!, interneurons_adjustment!,
|
precision, calculate_w_change!, store_knowledgefn_error!, interneurons_adjustment!,
|
||||||
reset_z_t!, resetLearningParams!, reset_learning_history_params!, reset_epsilonRec!,
|
reset_z_t!, resetLearningParams!, reset_learning_history_params!, reset_epsilonRec!,
|
||||||
reset_epsilonRecA!,
|
reset_epsilonRecA!, synapticConnStrength!,
|
||||||
firing_rate_error!, firing_rate_regulator!, update_Bn!, cal_firing_reg!,
|
firing_rate_error!, firing_rate_regulator!, update_Bn!, cal_firing_reg!,
|
||||||
neuroplasticity!, shakeup!, reset_learning_no_wchange!, adjust_internal_learning_rate!,
|
neuroplasticity!, shakeup!, reset_learning_no_wchange!, adjust_internal_learning_rate!,
|
||||||
gradient_withloss
|
gradient_withloss
|
||||||
|
|
||||||
using Statistics, Random, LinearAlgebra, Distributions, Zygote, Flux
|
using Statistics, Random, LinearAlgebra, Distributions, Zygote, Flux
|
||||||
|
using GeneralUtils
|
||||||
using ..types
|
using ..types
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------100
|
#------------------------------------------------------------------------------------------------100
|
||||||
@@ -298,22 +298,21 @@ function synapticConnStrength(currentStrength::AbstractFloat, updown::String, bi
|
|||||||
return updatedStrength
|
return updatedStrength
|
||||||
end
|
end
|
||||||
|
|
||||||
function synapticConnStrength(n::compute_neuron)
|
function synapticConnStrength!(n::Union{compute_neuron, output_neuron})
|
||||||
for (i, connStrength) in enumerate(n.synapticStrength)
|
for (i, connStrength) in enumerate(n.synapticStrength)
|
||||||
#WORKING
|
#WORKING
|
||||||
# check whether connStrength increase or decrease based on usage from n.epsilonRec
|
# check whether connStrength increase or decrease based on usage from n.epsilonRec
|
||||||
|
updown = n.epsilonRec[i] == 0.0 ? "down" : "up"
|
||||||
# compute synaptic strength for this conn
|
updatedConnStrength = synapticConnStrength(connStrength, updown)
|
||||||
|
updatedConnStrength = GeneralUtils.limitvalue(updatedConnStrength,
|
||||||
# apply conn lowerlimit and upperlimit
|
n.synapticStrengthLimit.lowerlimit, n.synapticStrengthLimit.upperlimit)
|
||||||
|
|
||||||
# at lowerlimit, mark wRec at this position to 0. for new random synaptic conn
|
# at lowerlimit, mark wRec at this position to 0. for new random synaptic conn
|
||||||
|
if updatedConnStrength == n.synapticStrengthLimit.lowerlimit[1]
|
||||||
|
n.wRec[i] = 0.0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
function synapticConnStrength!(n::input_neuron) end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module types
|
|||||||
export
|
export
|
||||||
# struct
|
# struct
|
||||||
IronpenStruct, model, knowledgeFn, lif_neuron, alif_neuron, linear_neuron,
|
IronpenStruct, model, knowledgeFn, lif_neuron, alif_neuron, linear_neuron,
|
||||||
kfn_1, compute_neuron, neuron, output_neuron, passthrough_neuron,
|
kfn_1, input_neuron, compute_neuron, neuron, output_neuron, passthrough_neuron,
|
||||||
|
|
||||||
# function
|
# function
|
||||||
instantiate_custom_types, init_neuron, populate_neuron,
|
instantiate_custom_types, init_neuron, populate_neuron,
|
||||||
|
|||||||
Reference in New Issue
Block a user