diff --git a/Runtime/Scripts/Core/Cluster.cs b/Runtime/Scripts/Core/Cluster.cs index 7ee9aa6..d4983ce 100644 --- a/Runtime/Scripts/Core/Cluster.cs +++ b/Runtime/Scripts/Core/Cluster.cs @@ -969,15 +969,11 @@ namespace NanoBrain { public void ProcessWeights(Func processor) { if (processor is null) throw new ArgumentNullException(nameof(processor)); - int thisNucleiCount = this.nuclei.Count; - - for (int i = 0; i < thisNucleiCount; i++) { - if (this.nuclei[i] is Neuron thisNeuron) { + for (int i = 0; i < this.nuclei.Count; i++) { + if (this.nuclei[i] is Neuron thisNeuron) thisNeuron.ProcessWeight(processor); - } - } - + } } #region Receivers diff --git a/Runtime/Scripts/Core/Neuron.cs b/Runtime/Scripts/Core/Neuron.cs index bbe8330..85552bd 100644 --- a/Runtime/Scripts/Core/Neuron.cs +++ b/Runtime/Scripts/Core/Neuron.cs @@ -349,15 +349,10 @@ namespace NanoBrain { } public void ProcessWeight(Func processor) { - int thisSynapseCount = this.synapses.Count; - - for (int i = 0; i < thisSynapseCount; i++) { - Synapse thisSynapse = this.synapses[i]; - if (thisSynapse.trainable) { + foreach (Synapse thisSynapse in this.synapses) { + if (thisSynapse.trainable) thisSynapse.weight = processor(thisSynapse.weight); - } } - } /// diff --git a/Runtime/Scripts/Core/Population.cs b/Runtime/Scripts/Core/Population.cs index 8a5f6fc..0a19b6b 100644 --- a/Runtime/Scripts/Core/Population.cs +++ b/Runtime/Scripts/Core/Population.cs @@ -57,14 +57,11 @@ namespace NanoBrain { Cluster result = members[0].brain.Copy(); for (int memberIx = 1; memberIx < members.Count; memberIx++) { - // Debug.Log($"{((Neuron)result.nuclei[0]).synapses[0].weight}"); Member member = members[memberIx]; result.ProcessWeightsFrom(member.brain, Sum); } - // Debug.Log($"R {((Neuron)result.nuclei[0]).synapses[0].weight}"); result.ProcessWeights(w => w / members.Count); - // Debug.Log($"A {((Neuron)result.nuclei[0]).synapses[0].weight}"); return result; }