rnd weight init

This commit is contained in:
Pascal Serrarens 2026-08-11 12:55:59 +02:00
parent e41bd74b5d
commit c7a57ccaf7

View File

@ -378,6 +378,23 @@ namespace NanoBrain {
return -1;
}
/// <summary>
/// Initializes all trainable weights to random values
/// </summary>
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