PGelss / scikit_tt

Tensor Train Toolbox
GNU Lesser General Public License v3.0
104 stars 25 forks source link

tt2qtt #8

Open qxy4212 opened 4 years ago

qxy4212 commented 4 years ago

Hi Dr. Gelß, Thanks a lot for this awesome library,I am a novice in this field ,Can you give me an example in line 990?t_qtt = tt2qtt(t, [M_1, ..., M_d], [N_1, ..., N_d])

Thanks

PGelss commented 4 years ago

Hello,

thank you for your interest in our toolbox. For the conversion from tt to qtt (or in other words the further splitting of a given set of TT cores), you can try the following code:

import scikit_tt.tensor_train as tt

# create a random tensor-train operator with rank 2
t = tt.rand([2, 4, 8], [3, 6, 12], ranks = 2)
print(t)

# split the second core into two and the third core into 3 cores
t_qtt = t.tt2qtt([[2], [2, 2], [2, 2, 2]], [[3], [2, 3], [2, 2, 3]])
print(t_qtt)

t is an order-3 tensor train with row dimensions (2, 4, 8) and column dimensions (3, 6, 12), whereas t_qtt is an order-6 tensor with row dimensions (2, 2, 2, 2, 2, 2) and column dimensions (3, 2, 3, 2, 2, 3). However, their matricizations would be the same (up to numerical errors). Note that the product of the entries in each of the sublists must be equal to the original dimensions, e.g., 12 = 2*2*3.

Best regards, Patrick