fix neuroplasticity error
This commit is contained in:
@@ -323,7 +323,7 @@ function lifLearn(wRec,
|
|||||||
zitCumulative_cpu = zitCumulative_cpu[:,:,1] # (row, col)
|
zitCumulative_cpu = zitCumulative_cpu[:,:,1] # (row, col)
|
||||||
|
|
||||||
# weak / negative synaptic connection will get randomed in neuroplasticity()
|
# weak / negative synaptic connection will get randomed in neuroplasticity()
|
||||||
wRec_cpu = GeneralUtils.replaceBetween.(wRec_cpu, 0.0, 0.1, -1.0) # mark with -1.0
|
wRec_cpu = GeneralUtils.replaceBetween.(wRec_cpu, 0.0, 0.01, -1.0) # mark with -1.0
|
||||||
|
|
||||||
# synaptic connection that has no activity will get randomed in neuroplasticity()
|
# synaptic connection that has no activity will get randomed in neuroplasticity()
|
||||||
mask = isless.(synapticInactivityCounter_cpu, -10_000)
|
mask = isless.(synapticInactivityCounter_cpu, -10_000)
|
||||||
@@ -375,7 +375,7 @@ function alifLearn(wRec,
|
|||||||
zitCumulative_cpu = zitCumulative_cpu[:,:,1] # (row, col)
|
zitCumulative_cpu = zitCumulative_cpu[:,:,1] # (row, col)
|
||||||
|
|
||||||
# weak / negative synaptic connection will get randomed in neuroplasticity()
|
# weak / negative synaptic connection will get randomed in neuroplasticity()
|
||||||
wRec_cpu = GeneralUtils.replaceBetween.(wRec_cpu, 0.0, 0.1, -1.0) # mark with -1.0
|
wRec_cpu = GeneralUtils.replaceBetween.(wRec_cpu, 0.0, 0.01, -1.0) # mark with -1.0
|
||||||
|
|
||||||
# synaptic connection that has no activity will get randomed in neuroplasticity()
|
# synaptic connection that has no activity will get randomed in neuroplasticity()
|
||||||
mask = isless.(synapticInactivityCounter_cpu, -10_000)
|
mask = isless.(synapticInactivityCounter_cpu, -10_000)
|
||||||
@@ -437,7 +437,7 @@ function neuroplasticity(synapticConnectionNumber,
|
|||||||
projection = ones(i1,i2,i3)
|
projection = ones(i1,i2,i3)
|
||||||
zitMask = zitMask .* projection # (row, col, n)
|
zitMask = zitMask .* projection # (row, col, n)
|
||||||
totalNewConn = sum(isequal.(wRec, -1.0), dims=(1,2)) # count new conn mark (-1.0), (1, 1, n)
|
totalNewConn = sum(isequal.(wRec, -1.0), dims=(1,2)) # count new conn mark (-1.0), (1, 1, n)
|
||||||
# println("neuroplasticity, from $synapticConnectionNumber, $totalNewConn are replaced")
|
println("neuroplasticity, from $synapticConnectionNumber, $totalNewConn are replaced")
|
||||||
|
|
||||||
# clear -1.0 marker
|
# clear -1.0 marker
|
||||||
GeneralUtils.replace_elements!(wRec, -1.0, synapticInactivityCounter, -0.99)
|
GeneralUtils.replace_elements!(wRec, -1.0, synapticInactivityCounter, -0.99)
|
||||||
|
|||||||
@@ -74,22 +74,11 @@ function addNewSynapticConn!(mask::AbstractArray{<:Any}, x::Number, wRec::Abstra
|
|||||||
selected = indices[1:n]
|
selected = indices[1:n]
|
||||||
# replace the elements in wRec at the selected positions with a
|
# replace the elements in wRec at the selected positions with a
|
||||||
for i in selected
|
for i in selected
|
||||||
wRec[i] = 0.1 #rand(0.1:0.01:0.3)
|
wRec[i] = rand(0.01:0.01:0.1)
|
||||||
if counter !== nothing
|
if counter !== nothing
|
||||||
counter[i] = 0 # reset
|
counter[i] = 0 # reset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# println("==================")
|
|
||||||
# println("mask ", mask, size(mask))
|
|
||||||
# println("")
|
|
||||||
# println("x ", x, size(x))
|
|
||||||
# println("")
|
|
||||||
# println("wRec ", wRec, size(wRec))
|
|
||||||
# println("")
|
|
||||||
# println("counter ", counter, size(counter))
|
|
||||||
# println("")
|
|
||||||
# println("n ", n, size(n))
|
|
||||||
# println("")
|
|
||||||
# error("DEBUG addNewSynapticConn!")
|
# error("DEBUG addNewSynapticConn!")
|
||||||
return remaining
|
return remaining
|
||||||
end
|
end
|
||||||
@@ -125,8 +114,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -370,14 +370,14 @@ function wRec(row, col, n, synapticConnectionNumber)
|
|||||||
for slice in eachslice(w, dims=3)
|
for slice in eachslice(w, dims=3)
|
||||||
pool = shuffle!([1:row*col...])[1:synapticConnectionNumber]
|
pool = shuffle!([1:row*col...])[1:synapticConnectionNumber]
|
||||||
for i in pool
|
for i in pool
|
||||||
slice[i] = rand() # assign weight to synaptic connection. /10 to start small,
|
slice[i] = rand(0.01:0.01:0.1) # assign weight to synaptic connection. /10 to start small,
|
||||||
# otherwise RSNN's vt Usually stay negative (-)
|
# otherwise RSNN's vt Usually stay negative (-)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 10% of neuron connection should be enough to start to make neuron fires
|
# 10% of neuron connection should be enough to start to make neuron fires
|
||||||
avgWeight = sum(w)/length(w)
|
avgWeight = sum(w)/length(w)
|
||||||
w = w .* (0.1 / avgWeight) # adjust overall weight
|
w = w .* (0.01 / avgWeight) # adjust overall weight
|
||||||
|
|
||||||
return w #(row, col, n)
|
return w #(row, col, n)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user