Skip to content

__truediv__ does not protect against division by zero #10

Description

@github-actions

File: leanpass/tensor.py

The division operator implements self.data / other.data and the backward pass uses other.data ** 2. If other.data contains zeros, NumPy will emit inf/nan and gradients become undefined. Typical autograd libraries raise an error or return a large finite gradient.

Fix: Add a small epsilon to the denominator (e.g., den = other.data + eps) and use the same epsilon in the backward computation, or explicitly check for zeros and raise a clear exception.

File: leanpass/tensor.py

Filed automatically by ai-issue-scan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions