change from end of sample learning to online learning

This commit is contained in:
2023-05-26 21:03:03 +07:00
parent 3556167591
commit b0cede75c1
6 changed files with 146 additions and 152 deletions

View File

@@ -1,8 +1,6 @@
module forward
using Flux.Optimise: apply!
using Statistics, Flux, Random, LinearAlgebra, JSON3
using Statistics, Random, LinearAlgebra, JSON3
using GeneralUtils
using ..types, ..snn_utils
@@ -77,19 +75,17 @@ function (kfn::kfn_1)(m::model, input_data::AbstractVector)
kfn.firedNeurons_t0 = [n.z_t for n in kfn.neuronsArray] #TODO check if it is used?
Threads.@threads for n in kfn.neuronsArray
# for n in kfn.neuronsArray
# Threads.@threads for n in kfn.neuronsArray
for n in kfn.neuronsArray
n(kfn)
end
kfn.firedNeurons_t1 = [n.z_t1 for n in kfn.neuronsArray]
append!(kfn.firedNeurons, findall(kfn.firedNeurons_t1)) # store id of neuron that fires
if kfn.learningStage == "end_learning"
kfn.firedNeurons |> unique! # use for random new neuron connection
end
kfn.firedNeurons |> unique! # use for random new neuron connection
Threads.@threads for n in kfn.outputNeuronsArray
# for n in kfn.outputNeuronsArray
# Threads.@threads for n in kfn.outputNeuronsArray
for n in kfn.outputNeuronsArray
n(kfn)
end