fix(hebbian): random weight init to escape zero local minimum
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
import binary_encoding
|
import binary_encoding
|
||||||
import std/math
|
import std/math
|
||||||
|
import std/random
|
||||||
|
|
||||||
const
|
const
|
||||||
N_IN* = TOTAL_BITS # 870
|
N_IN* = TOTAL_BITS # 870
|
||||||
@@ -31,7 +32,8 @@ type
|
|||||||
active*: bool
|
active*: bool
|
||||||
|
|
||||||
proc initHebbianNet*(): HebbianNet =
|
proc initHebbianNet*(): HebbianNet =
|
||||||
discard # zero-init by default
|
for w in result.W.mitems:
|
||||||
|
w = rand(0.2) - 0.1
|
||||||
|
|
||||||
proc forward*(net: HebbianNet, input: BinaryVector): OutputVector =
|
proc forward*(net: HebbianNet, input: BinaryVector): OutputVector =
|
||||||
for j in 0..<N_OUT:
|
for j in 0..<N_OUT:
|
||||||
|
|||||||
Reference in New Issue
Block a user