Skip to content

sum and mean backward do not support tuple axes #49

Description

@github-actions

File: leanpass/tensor.py

Both Tensor.sum and Tensor.mean assume axis is either None or a single integer. When a tuple of axes is supplied (e.g., axis=(1,2)), the backward pass calls np.expand_dims(grad, axis=axis) which raises a TypeError. This breaks expected NumPy‑style behavior. The implementation should iterate over the tuple or use np.expand_dims in a loop to correctly reshape the gradient before broadcasting.

Filed automatically by ai-issue-scan.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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