t3toolbox.uniform_basis_variations_format.ubv_to_ut3#

t3toolbox.uniform_basis_variations_format.ubv_to_ut3(ii: int, use_tt_variation: bool, basis: UT3Basis, variations: UT3Variations) t3toolbox.uniform_tucker_tensor_train.UniformTuckerTensorTrain#

Convert basis-variations representation to TuckerTensorTrain.

If replacement_ind=1, replace_tt=True:

1 -- L0 --(H1)-- R2 -- R3 -- 1
     |     |     |     |
     U0    U1    U2    U3
     |     |     |     |

If replacement_ind=2, replace_tt=False:

1 -- L0 -- L1 -- O2 -- R3 -- 1
     |     |     |     |
     U0    U1   (V2)   U3
     |     |     |     |
ii: int

Index of variation. 0 <= replacement_ind < num_cores

replace_tt: bool

Indicates whether to use TT variation (True) or a Tucker variation (False)

base: T3Basis

Basis cores

variations: T3Variations

Variation cores

RuntimeError
  • Error raised if the basis and variations do not fit with each other

import t3toolbox.backend.basis_variations_format.bv_conversions >>> import numpy as np
>>> import t3toolbox.basis_variations_format as bcf
>>> randn = np.random.randn # shorthand
>>> (U0,U1,U2) = (randn(10, 14), randn(11, 15), randn(12, 16))
>>> (L0,L1,L2) = (randn(1, 10, 2), randn(2, 11, 3), randn(3,12,4))
>>> (R0,R1,R2) = (randn(2,10,4), randn(4, 11, 5), randn(5, 12, 1))
>>> (O0,O1,O2) = (randn(1, 9, 4), randn(2, 8, 5), randn(3, 7, 1))
>>> base = bcf.T3Basis((U0,U1,U2), (L0,L1,L2), (R0,R1,R2), (O0,O1,O2))
>>> (V0,V1,V2) = (randn(9,14), randn(8,15), randn(7,16))
>>> (H0,H1,H2) = (randn(1,10,4), randn(2,11,5), randn(3,12,1))
>>> variations = bcf.T3Variations((V0,V1,V2), (H0,H1,H2))
>>> ((B0, B1, B2), (G0, G1, G2)) = t3toolbox.backend.basis_variations_format.bv_conversions.bv_to_t3(1, True, base, variations).data # replace index-1 TT-backend
>>> print(((B0,B1,B2), (G0,G1,G2)) == ((U0,U1,U2), (L0,H1,R2)))
True
import t3toolbox.backend.basis_variations_format.bv_conversions >>> ((B0, B1, B2), (G0, G1, G2)) = t3toolbox.backend.basis_variations_format.bv_conversions.bv_to_t3(1, False, base, variations).data # replace index-1 tucker backend
>>> print(((B0,B1,B2), (G0,G1,G2)) == ((U0,V1,U2), (L0,O1,R2)))
True