Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display tensors by frontal slice rather than lateral slice #338

Open
tgkolda opened this issue Nov 13, 2024 · 0 comments
Open

Display tensors by frontal slice rather than lateral slice #338

tgkolda opened this issue Nov 13, 2024 · 0 comments

Comments

@tgkolda
Copy link

tgkolda commented Nov 13, 2024

The default display in pyttb is to display the 2D slices w.r.t. the last 2 modes. This is in contrast to MATLAB which displays them w.r.t. the first two modes. For a 3-way tensor, pyttb displays the lateral slices rather than the frontal slices. I think it should be changed or at least there should be a function that displays it the MATLAB TTB way.

Example in MATLAB:

X = tensor([1:8],[2 2 2])

Output:

X is a tensor of size 2 x 2 x 2
	X(:,:,1) = 
	     1     3
	     2     4
	X(:,:,2) = 
	     5     7
	     6     8

Same example in Python:

Y = ttb.tensor(np.arange(1,9), (2, 2, 2));
Y

Output:

tensor of shape (2, 2, 2)
data[0, :, :] =
[[1 5]
 [3 7]]
data[1, :, :] =
[[2 6]
 [4 8]]

I expect these display orders are artifacts of the underlying default storage. By default, MATLAB prints in such a way that it's linear in memory. Python uses the opposite ordering by default, so it's perhaps not surprising that its printing is in the opposite order. But since pyttb is storing things in the MATLAB order internally, it should also print them this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant