rnd weight init
This commit is contained in:
parent
e41bd74b5d
commit
c7a57ccaf7
@ -378,6 +378,23 @@ namespace NanoBrain {
|
|||||||
return -1;
|
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
|
#endregion Init
|
||||||
|
|
||||||
#region Cluster Array
|
#region Cluster Array
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user