t3toolbox.basis_variations_format.bv_to_t3#
- t3toolbox.basis_variations_format.bv_to_t3(index: t3toolbox.backend.common.typ.Tuple[bool, int], basis: T3Basis, variations: T3Variations) t3toolbox.tucker_tensor_train.TuckerTensorTrain#
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 -- D2 -- 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 bvf >>> 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)) >>> (D0,D1,D2) = (randn(1, 9, 4), randn(2, 8, 5), randn(3, 7, 1)) >>> base = bvf.T3Basis((U0,U1,U2), (D0,D1,D2), (L0,L1,L2), (R0,R1,R2)) >>> (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 = bvf.T3Variations((V0,V1,V2), (H0,H1,H2)) >>> ((B0, B1, B2), (G0, G1, G2)) = t3toolbox.backend.basis_variations_format.bv_conversions.bv_to_t3((True, 1), base, variations).data # replace index-1 TT-core >>> 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((False, 1), base, variations).data # replace index-1 tucker core
>>> print(((B0,B1,B2), (G0,G1,G2)) == ((U0,V1,U2), (L0,D1,R2))) True