Skip to content

Commit 202d484

Browse files
committed
fix: do not kill weight due to L1 regularization type
1 parent d4ab4a0 commit 202d484

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/playground/nn.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -412,21 +412,7 @@ export function updateNode (node: Node): void {
412412
link.weight = link.weight - (learningRate / link.numAccumulatedDers) * link.accErrorDer;
413413

414414
// Further update the weight based on regularization.
415-
let newLinkWeight = link.weight - (learningRate * regularizationRate) * regulDer;
416-
417-
// todo investigate
418-
if (
419-
regularization === RegularizationFunction.L1
420-
&& link.weight * newLinkWeight < 0
421-
) {
422-
// The weight crossed 0 due to the regularization term. Set it to 0.
423-
link.weight = 0;
424-
link.isDead = true;
425-
}
426-
else {
427-
link.weight = newLinkWeight;
428-
}
429-
415+
link.weight = link.weight - (learningRate * regularizationRate) * regulDer;
430416
link.accErrorDer = 0;
431417
link.numAccumulatedDers = 0;
432418
}

0 commit comments

Comments
 (0)