temp
This commit is contained in:
86
src/learn.jl
86
src/learn.jl
@@ -325,7 +325,6 @@ function lifLearn!(wRec,
|
||||
# reset lif_inactivity elements to -9
|
||||
GeneralUtils.replace_elements!(neuronInactivityCounter_cpu, 0.0, -9.0) # -9.0 is base value
|
||||
|
||||
|
||||
#WORKING neuroplasticity
|
||||
wRec_cpu = neuroplasticity(synapticConnectionNumber,
|
||||
zitCumulative_cpu,
|
||||
@@ -377,15 +376,17 @@ end
|
||||
function neuroplasticity(synapticConnectionNumber,
|
||||
zitCumulative, # (row, col)
|
||||
wRec, # (row, col, n)
|
||||
neuronInactivityCounter, #WORKING neuron die i.e. reset all weight
|
||||
synapticInactivityCounter) # (row, col, n)
|
||||
neuronInactivityCounter,
|
||||
synapticInactivityCounter) # (row, col, n)
|
||||
#WORKING
|
||||
# - synapticInactivityCounter -10000 to 10000, weight liquidity range from 1.0 to 0.1 respectively
|
||||
# - at synapticInactivityCounter -10000 mark -1.0 for new conn
|
||||
|
||||
i1,i2,i3 = size(wRec)
|
||||
|
||||
# for each neuron, find total number of synaptic conn that should draw
|
||||
# new connection to firing and non-firing neurons pool
|
||||
subToFireNeuron_toBe = Int(floor(0.7 * synapticConnectionNumber))
|
||||
subToNonFiringNeuron_toBe = synapticConnectionNumber - subToFireNeuron_toBe
|
||||
|
||||
# for each neuron, count how many synap already subscribed to firing-neurons
|
||||
zw = zitCumulative .* wRec
|
||||
@@ -395,17 +396,23 @@ function neuroplasticity(synapticConnectionNumber,
|
||||
zitMask = zitMask .* projection # (row, col, n)
|
||||
totalNewConn = sum(isequal.(wRec, -1.0), dims=(1,2)) # count new conn mark (-1.0), (1, 1, n)
|
||||
|
||||
#WORKING clear -1.0 marker
|
||||
# clear -1.0 marker
|
||||
GeneralUtils.replace_elements!(wRec, -1.0, synapticInactivityCounter, -0.99)
|
||||
GeneralUtils.replace_elements!(wRec, -1.0, 0.0) # -1.0 marker is no longer required
|
||||
|
||||
println("/////////")
|
||||
println("zitCumulative ", zitCumulative)
|
||||
println("neuronInactivityCounter ", size(neuronInactivityCounter))
|
||||
println("wRec 1 ", wRec[:,:,1])
|
||||
println("synapticInactivityCounter 1 ", synapticInactivityCounter[:,:,1])
|
||||
println("synapticInactivityCounter 1 ", neuronInactivityCounter[1,1,:], synapticInactivityCounter[:,:,1])
|
||||
println("wRec 2 ", wRec[:,:,2])
|
||||
println("synapticInactivityCounter 2 ", synapticInactivityCounter[:,:,2])
|
||||
|
||||
for i in 1:i3
|
||||
# if neuronInactivityCounter[1:1:i] <= -10000
|
||||
# w = wRec(i1,i2,1,) #WORKING neuron die i.e. reset all weight
|
||||
|
||||
|
||||
remaining = 0
|
||||
if subToFireNeuron_current[1,1,i] < subToFireNeuron_toBe
|
||||
toAddConn = subToFireNeuron_toBe - subToFireNeuron_current[1,1,i]
|
||||
@@ -442,6 +449,73 @@ end
|
||||
|
||||
|
||||
|
||||
# function neuroplasticity(synapticConnectionNumber,
|
||||
# zitCumulative, # (row, col)
|
||||
# wRec, # (row, col, n)
|
||||
# neuronInactivityCounter, #WORKING neuron die i.e. reset all weight
|
||||
# synapticInactivityCounter) # (row, col, n)
|
||||
|
||||
# i1,i2,i3 = size(wRec)
|
||||
|
||||
# # for each neuron, find total number of synaptic conn that should draw
|
||||
# # new connection to firing and non-firing neurons pool
|
||||
# subToFireNeuron_toBe = Int(floor(0.7 * synapticConnectionNumber))
|
||||
# subToNonFiringNeuron_toBe = synapticConnectionNumber - subToFireNeuron_toBe
|
||||
|
||||
# # for each neuron, count how many synap already subscribed to firing-neurons
|
||||
# zw = zitCumulative .* wRec
|
||||
# subToFireNeuron_current = sum(GeneralUtils.isBetween.(zw, 0.0, 100.0), dims=(1,2)) # (1, 1, n)
|
||||
# zitMask = (!iszero).(zitCumulative) # zitMask of firing neurons = 1, non-firing = 0
|
||||
# projection = ones(i1,i2,i3)
|
||||
# zitMask = zitMask .* projection # (row, col, n)
|
||||
# totalNewConn = sum(isequal.(wRec, -1.0), dims=(1,2)) # count new conn mark (-1.0), (1, 1, n)
|
||||
|
||||
# # clear -1.0 marker
|
||||
# GeneralUtils.replace_elements!(wRec, -1.0, synapticInactivityCounter, -0.99)
|
||||
# GeneralUtils.replace_elements!(wRec, -1.0, 0.0) # -1.0 marker is no longer required
|
||||
|
||||
# println("/////////")
|
||||
# println("zitCumulative ", zitCumulative)
|
||||
# println("wRec 1 ", wRec[:,:,1])
|
||||
# println("synapticInactivityCounter 1 ", synapticInactivityCounter[:,:,1])
|
||||
# println("wRec 2 ", wRec[:,:,2])
|
||||
# println("synapticInactivityCounter 2 ", synapticInactivityCounter[:,:,2])
|
||||
|
||||
# for i in 1:i3
|
||||
# remaining = 0
|
||||
# if subToFireNeuron_current[1,1,i] < subToFireNeuron_toBe
|
||||
# toAddConn = subToFireNeuron_toBe - subToFireNeuron_current[1,1,i]
|
||||
# totalNewConn[1,1,i] = totalNewConn[1,1,i] - toAddConn
|
||||
# # add new conn to firing neurons pool
|
||||
# remaining = addNewSynapticConn!(zitMask[:,:,i], 1,
|
||||
# @view(wRec[:,:,i]),
|
||||
# @view(synapticInactivityCounter[:,:,i]),
|
||||
# toAddConn)
|
||||
# totalNewConn[1,1,i] += remaining
|
||||
# end
|
||||
|
||||
# # add new conn to non-firing neurons pool
|
||||
# remaining = addNewSynapticConn!(zitMask[:,:,i], 0,
|
||||
# @view(wRec[:,:,i]),
|
||||
# @view(synapticInactivityCounter[:,:,i]),
|
||||
# totalNewConn[1,1,i])
|
||||
# if remaining > 0 # final get-all round if somehow non-firing pool has not enough slot
|
||||
# remaining = addNewSynapticConn!(zitMask[:,:,i], 1,
|
||||
# @view(wRec[:,:,i]),
|
||||
# @view(synapticInactivityCounter[:,:,i]),
|
||||
# remaining)
|
||||
# end
|
||||
# end
|
||||
# println("==========")
|
||||
# println("wRec 1 ", wRec[:,:,1])
|
||||
# println("synapticInactivityCounter 1 ", synapticInactivityCounter[:,:,1])
|
||||
# println("wRec 2 ", wRec[:,:,2])
|
||||
# println("synapticInactivityCounter 2 ", synapticInactivityCounter[:,:,2])
|
||||
|
||||
# # error("DEBUG -> neuroplasticity $(Dates.now())")
|
||||
# return wRec
|
||||
# end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user