Skip to content

Tensor.log does not guard against non‑positive inputs #24

Description

@github-actions

File: leanpass/tensor.py

Calling log() on a tensor containing zeros or negative numbers yields -inf or nan without any warning, which propagates through the graph and makes training unstable. The implementation should either raise a clear error for invalid inputs or clamp the values to a small positive epsilon before applying np.log.

def log(self):
-    out = self._create_child(np.log(self.data), "log", {self})
+    if np.any(self.data <= 0):
+        raise ValueError("log() received non‑positive values")
+    out = self._create_child(np.log(self.data), "log", {self})

Filed automatically by ai-issue-scan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions