From c7a57ccaf7cc947f1c70efd2f5cef8157f72fe8d Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 11 Aug 2026 12:55:59 +0200 Subject: [PATCH] rnd weight init --- Runtime/Scripts/Core/Cluster.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Runtime/Scripts/Core/Cluster.cs b/Runtime/Scripts/Core/Cluster.cs index 96bddd9..ca193e6 100644 --- a/Runtime/Scripts/Core/Cluster.cs +++ b/Runtime/Scripts/Core/Cluster.cs @@ -378,6 +378,23 @@ namespace NanoBrain { return -1; } + /// + /// Initializes all trainable weights to random values + /// + public void InitializeRandom() { + System.Random randomGenerator = new(); + foreach (Nucleus nucleus in this.nuclei) { + if (nucleus is Neuron neuron) { + foreach (Synapse synapse in neuron.synapses) { + if (synapse.trainable) { + synapse.weight = (float)randomGenerator.NextDouble() * 2.0f - 1.0f; + //Debug.Log($"{neuron.name}-{synapse.neuron.name} weight = {synapse.weight}"); + } + } + } + } + } + #endregion Init #region Cluster Array