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