temp
This commit is contained in:
49
src/type.jl
49
src/type.jl
@@ -196,20 +196,8 @@ function kfn_1(params::Dict; device=cpu)
|
||||
lif_n = kfn.params[:computeNeuron][:lif][:numbers][1] * kfn.params[:computeNeuron][:lif][:numbers][2]
|
||||
|
||||
# subscription
|
||||
w = zeros(row, col, lif_n)
|
||||
synapticConnectionPercent = kfn.params[:computeNeuron][:lif][:params][:synapticConnectionPercent]
|
||||
kfn.lif_synapticConnectionNumber = Int(floor(row*col * synapticConnectionPercent/100))
|
||||
for slice in eachslice(w, dims=3)
|
||||
pool = shuffle!([1:row*col...])[1:kfn.lif_synapticConnectionNumber]
|
||||
for i in pool
|
||||
slice[i] = rand() # assign weight to synaptic connection. /10 to start small,
|
||||
# otherwise RSNN's vt Usually stay negative (-)
|
||||
end
|
||||
end
|
||||
|
||||
# 10% of neuron connection should be enough to start to make neuron fires
|
||||
should_be_avg_weight = 1 / (0.1 * lif_n)
|
||||
w = w .* (should_be_avg_weight / maximum(w)) # adjust overall weight
|
||||
kfn.lif_synapticConnectionNumber, w = wRec(row, col, lif_n, synapticConnectionPercent)
|
||||
|
||||
# project 3D w into 4D kfn.lif_wRec (row, col, n, batch)
|
||||
kfn.lif_wRec = reshape(w, (row, col, lif_n, 1)) .* ones(row, col, lif_n, batch) |> device
|
||||
@@ -234,7 +222,7 @@ function kfn_1(params::Dict; device=cpu)
|
||||
|
||||
kfn.lif_firingCounter = (similar(kfn.lif_wRec) .= 0)
|
||||
kfn.lif_firingTargetFrequency = (similar(kfn.lif_wRec) .= 0.1)
|
||||
kfn.lif_neuronInactivityCounter = (similar(kfn.lif_wRec) .= 10000)
|
||||
kfn.lif_neuronInactivityCounter = (similar(kfn.lif_wRec) .= 0)
|
||||
kfn.lif_synapticInactivityCounter = Array(similar(kfn.lif_wRec) .= -0.99) # -9 for non-sub conn
|
||||
mask = Array((!iszero).(kfn.lif_wRec))
|
||||
GeneralUtils.replace_elements!(mask, 1, kfn.lif_synapticInactivityCounter, 0) # initial value subscribed conn
|
||||
@@ -255,20 +243,8 @@ function kfn_1(params::Dict; device=cpu)
|
||||
alif_n = kfn.params[:computeNeuron][:alif][:numbers][1] * kfn.params[:computeNeuron][:alif][:numbers][2]
|
||||
|
||||
# subscription
|
||||
w = zeros(row, col, alif_n)
|
||||
synapticConnectionPercent = kfn.params[:computeNeuron][:alif][:params][:synapticConnectionPercent]
|
||||
kfn.alif_synapticConnectionNumber = Int(floor(row*col * synapticConnectionPercent/100))
|
||||
for slice in eachslice(w, dims=3)
|
||||
pool = shuffle!([1:row*col...])[1:kfn.alif_synapticConnectionNumber]
|
||||
for i in pool
|
||||
slice[i] = rand() # assign weight to synaptic connection. /10 to start small,
|
||||
# otherwise RSNN's vt Usually stay negative (-)
|
||||
end
|
||||
end
|
||||
|
||||
# 10% of neuron connection should be enough to start to make neuron fires
|
||||
should_be_avg_weight = 1 / (0.1 * alif_n)
|
||||
w = w .* (should_be_avg_weight / maximum(w)) # adjust overall weight
|
||||
kfn.alif_synapticConnectionNumber, w = wRec(row, col, alif_n, synapticConnectionPercent)
|
||||
|
||||
# project 3D w into 4D kfn.alif_wRec
|
||||
kfn.alif_wRec = reshape(w, (row, col, alif_n, 1)) .* ones(row, col, alif_n, batch) |> device
|
||||
@@ -293,7 +269,7 @@ function kfn_1(params::Dict; device=cpu)
|
||||
|
||||
kfn.alif_firingCounter = (similar(kfn.alif_wRec) .= 0)
|
||||
kfn.alif_firingTargetFrequency = (similar(kfn.alif_wRec) .= 0.1)
|
||||
kfn.alif_neuronInactivityCounter = (similar(kfn.alif_wRec) .= 10000)
|
||||
kfn.alif_neuronInactivityCounter = (similar(kfn.alif_wRec) .= 0)
|
||||
kfn.alif_synapticInactivityCounter = Array(similar(kfn.alif_wRec) .= -0.99) # -9 for non-sub conn
|
||||
mask = Array((!iszero).(kfn.alif_wRec))
|
||||
GeneralUtils.replace_elements!(mask, 1, kfn.alif_synapticInactivityCounter, 0) # initial value subscribed conn
|
||||
@@ -383,7 +359,24 @@ function kfn_1(params::Dict; device=cpu)
|
||||
return kfn
|
||||
end
|
||||
|
||||
function wRec(row, col, n, synapticConnectionPercent)
|
||||
# subscription
|
||||
w = zeros(row, col, n)
|
||||
synapticConnectionNumber = Int(floor(row*col * synapticConnectionPercent/100))
|
||||
for slice in eachslice(w, dims=3)
|
||||
pool = shuffle!([1:row*col...])[1:synapticConnectionNumber]
|
||||
for i in pool
|
||||
slice[i] = rand() # assign weight to synaptic connection. /10 to start small,
|
||||
# otherwise RSNN's vt Usually stay negative (-)
|
||||
end
|
||||
end
|
||||
|
||||
# 10% of neuron connection should be enough to start to make neuron fires
|
||||
should_be_avg_weight = 1 / (0.1 * synapticConnectionNumber)
|
||||
w = w .* (should_be_avg_weight / maximum(w)) # adjust overall weight
|
||||
|
||||
return synapticConnectionNumber, w
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user