File: leanpass/nn.py
Both loss functions compute log of probabilities directly. When the probability is exactly 0 (possible due to underflow in softmax or sigmoid), the log returns -inf, leading to NaNs in the loss and gradients.
Enhancement: add a small epsilon (e.g., 1e-12) to the probabilities before taking the log, or use a more stable formulation such as log_softmax for cross‑entropy.
This aligns the library with typical deep‑learning expectations.
Filed automatically by ai-issue-scan.
File:
leanpass/nn.pyBoth loss functions compute
logof probabilities directly. When the probability is exactly 0 (possible due to underflow insoftmaxorsigmoid), the log returns-inf, leading to NaNs in the loss and gradients.Enhancement: add a small epsilon (e.g.,
1e-12) to the probabilities before taking the log, or use a more stable formulation such aslog_softmaxfor cross‑entropy.This aligns the library with typical deep‑learning expectations.
Filed automatically by ai-issue-scan.