File: leanpass/tensor.py
The file defines _graph_nodes and grad_check twice. The second definitions overwrite the first ones, but the second grad_check is truncated (numeric[node] = ) and contains several bugs (calls node.zero_grad_all(), uses undefined self.zero_grad_all(), mismatched return types). This makes the gradient‑checking utility unusable and may silently break other code that expects the original implementation.
Fix: Remove the duplicated definitions. Keep a single, correct implementation of _graph_nodes (the first one is fine) and a complete, tested grad_check that:
- Uses
self.zero_grad_all() to clear grads.
- Computes numerical gradients correctly (e.g., using
np.sum(plus) - np.sum(minus) for scalar outputs).
- Returns a list of error tuples as documented.
File: leanpass/tensor.py
Filed automatically by ai-issue-scan.
File:
leanpass/tensor.pyThe file defines
_graph_nodesandgrad_checktwice. The second definitions overwrite the first ones, but the secondgrad_checkis truncated (numeric[node] =) and contains several bugs (callsnode.zero_grad_all(), uses undefinedself.zero_grad_all(), mismatched return types). This makes the gradient‑checking utility unusable and may silently break other code that expects the original implementation.Fix: Remove the duplicated definitions. Keep a single, correct implementation of
_graph_nodes(the first one is fine) and a complete, testedgrad_checkthat:self.zero_grad_all()to clear grads.np.sum(plus) - np.sum(minus)for scalar outputs).File:
leanpass/tensor.pyFiled automatically by ai-issue-scan.