fix(hebbian): symmetric learning — both active and inactive outputs learn

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-18 00:13:32 +02:00
parent f12bdf810e
commit dd78f3c239
2 changed files with 3 additions and 3 deletions
+3 -3
View File
@@ -48,6 +48,6 @@ proc learn*(net: var HebbianNet, trace: EligibilityTrace, reward: float) =
for i in 0..<N_IN:
if trace.input[i] == 1:
for j in 0..<N_OUT:
if trace.output[j] == 1:
net.W[i * N_OUT + j] += LEARNING_RATE * decayedReward
net.W[i * N_OUT + j] = clamp(net.W[i * N_OUT + j], -W_CLAMP, W_CLAMP)
let sign = if trace.output[j] == 1: 1.0 else: -1.0
net.W[i * N_OUT + j] += LEARNING_RATE * sign * decayedReward
net.W[i * N_OUT + j] = clamp(net.W[i * N_OUT + j], -W_CLAMP, W_CLAMP)