Skip to content

The transpose function is problematic #228

Closed
@rgommers

Description

@rgommers

There are multiple problems, both related to adoption due to conflicting definitions, and because NumPy's transpose does something no one really wants (namely, swap all axes).

The current array API transpose may not be correct:

PyTorch names the numpy.transpose equivalent permute, and PyTorch's transpose is np.swapaxes. Relevant issues PyTorch issues:

Relevant NumPy issues:

There's multiple ways of dealing with this problem:

  1. Accept the status quo
  2. Remove transpose completely, and use permute or some other function name with the behavior we want by default (do the right thing for batches of 2-D matrices)
  3. Add both, by adding a matrix_transpose function and a corresponding .mT (or .MT) attribute

I searched the JAX and TensorFlow issue trackers as well and, somewhat surprisingly, didn't find an issue about this topic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API changeChanges to existing functions or objects in the API.topic: Linear AlgebraLinear algebra.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions