question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The `transpose` function is problematic

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
shoyercommented, Jul 14, 2021

I think separating the functionality of np.transpose() into two separate functions/methods would make sense. As you note, there are two distinct use cases:

  1. Swap the last two dimensions
  2. Permute axes

The only real relation is that (1) can be implemented via (2).

From my perspective, the functionality (1) would be the best fit for the name “transpose”, and (2) could use some other name, like “permute axes”.

1reaction
rgommerscommented, Sep 15, 2021

permute_dims seems quite reasonable too. If we consistently name keywords axis/axes, using _dims for function names and ndim for attribute is at least some kind of consistency.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to correct a #VALUE! error in the TRANSPOSE function
Problem: The formula has not been entered as an array formula. Refer to the following example where we've used: =TRANSPOSE(B2:C8). #VALUE error in...
Read more >
Solved! The problem with Excel Tables and Transpose
The Transpose() function would seem ideal because it works from a source Excel table. BUT, the result isn't an Excel table and can't...
Read more >
google sheets - Problem using the TRANSPOSE() function
In an empty cell, I can use the function =TRANSPOSE(A1:A3) to get the rows switched into columns. My problem is that the three...
Read more >
Data transpose function in R not working properly
My data is in rows and the columns are different variables. When using the function phyDat, the author indicates a transpose function because ......
Read more >
TRANSPOSE formula problem
I'm not sure what I'm doing wrong, but I am trying to use the transpose formula to transpose row data to column headings...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found