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

The size of tt_reshape #70

Open
Yukwah1214 opened this issue May 16, 2024 · 1 comment
Open

The size of tt_reshape #70

Yukwah1214 opened this issue May 16, 2024 · 1 comment

Comments

@Yukwah1214
Copy link

When I was trying to use the function tt_reshape, I encountered the following problem:
It works when the code is :

tt_reshape(tt_eye(8),[2,2,2;2,2,2]')

but if I change the size:
tt_reshape(tt_eye(8),[4,4,4;1,1,1]')
it went wrong.

and if I change the size to:
tt_reshape(tt_eye(8),[4,1,4;1,4,1]')
it worked again!

I wonder what is the reason and what should I pay attention to when reshaping a TT tensor/matrix?
Maybe this is a simple question, but I really can't find the answer. Sincerely hope someone can help me answer

@dolgov
Copy link
Collaborator

dolgov commented May 16, 2024

Actually, I don't know how to reshape a tt_matrix. tt_tensor is easy: split a core of required size if you can, otherwise merge original cores until you can. For tt_matrix, you need to permute dimensions in different ways depending on what you want (you can't even tell this from sizes alone).

In your example in particular, splitting out a 4 x 1 core from a 8 x 8 matrix can be understood in at least the following ways:

  • consider the matrix as tt_eye(2,3), and reshape each core into a 4 x 1 matrix (perhaps what you want);
  • split the original full matrix into 4 x 2 x 1 x 8;
  • split the original full matrix into 4 x 1 x ...
    (the total number of ways is combinatorial I think).

The current code works if both row and column sizes can be reorganized by the same sequence of splits and merges. For anything more general I don't see how to write it consistently.

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

2 participants