fv_center_factors#

t3toolbox.backend.fv_operations.fv_center_factors(frame)#
def fv_center_factors(
        frame:  typ.Tuple[
            typ.Sequence[NDArray],  # down_tucker_cores. len=d, elm_shape=C+(nDi, Ni)
            typ.Sequence[NDArray],  # up_tt_cores.       len=d, elm_shape=C+(rLi, nUi, rR(i+1))
            typ.Sequence[NDArray],  # left_tt_cores.     len=d, elm_shape=C+(rLi, nDi, rL(i+1))
            typ.Sequence[NDArray],  # right_tt_cores.    len=d, elm_shape=C+(rRi, nDi, rR(i+1))
        ],
) -> typ.Tuple[
    typ.Tuple[NDArray, ...],        # centers H_i = L_i T_i.  len=d,   elm_shape=C+(rLi, nDi, rR(i+1))
    typ.Tuple[NDArray, ...],        # tucker factors S_i^T.   len=d,   elm_shape=C+(nUi, nDi)
    typ.Tuple[NDArray, ...],        # bond factors T_i.       len=d-1, elm_shape=C+(rL(i+1), rR(i+1))
]:

The small per-mode factors that an orthogonal frame’s construction produces and discards.

Recomputed from the STORED cores, by contraction only (no SVD):

  • the bond factors T_i (i <= d-2): the right-to-left zipper of the left chain against the right chain at bond i+1 (tt_zipper_right_to_left()). Because the base point is X = L_{<i} L_i T_i R_{>i}, T_i = <L_i, H_i> and its singular values are the TT singular values of X at bond i+1;

  • the centers H_i = L_i T_i (at the last mode the zipper is the boundary ones matrix – [[1]] on the usual squashed frame – so H_{d-1} = L_{d-1}): the base point’s core when the orthogonality center sits at mode i – the construction’s own TT variations of the point;

  • the Tucker factors S_i^T = <U_i, H_i> (shape nUi x nDi): the base point’s Tucker variation is V_i = S_i^T D_i, and the singular values of S_i are the mode-i Tucker singular values of X. In particular ||X||^2 = sum(sigma(S_0)^2) = ||S_0^T||_F^2.

The zipper recompute is GEMM-only, exact to roundoff, and consistent with the stored U/R whatever built the frame; nothing is re-SVD’d, so no sign or degenerate-block choice is made here (the measurements are in the sharing design record, docs/contributor/sharing_internals.md). The identities above presume an orthogonal frame (as from t3_orthogonal_representations); like every backend function this one is check-free.

Polymorphic: frame may also be the four uniform supercores ((d,)+C+(...)), indexed per mode – the uniform shared-frame companion relies on this. Two consumers: the shared geometry’s companion (fv_shared_frame_data(), the centers and S_i^T) and the exact Hessian’s lift (fv_lift_factors(), S_i^T and T_i).

Examples

The centers are the construction’s own, and the factors carry the dense tensor’s spectra:

>>> import numpy as np
>>> import t3toolbox.tucker_tensor_train as t3
>>> import t3toolbox.backend.fv_conversions as fvc
>>> import t3toolbox.backend.fv_operations as fvo
>>> np.random.seed(0)
>>> x = t3.TuckerTensorTrain.randn((5, 6, 7), (2, 3, 2), (1, 2, 2, 1))
>>> frame, variations = fvc.t3_orthogonal_representations(x.data)
>>> centers, tucker_factors_T, bond_factors = fvo.fv_center_factors(frame)
>>> print([S.shape for S in tucker_factors_T], [T.shape for T in bond_factors])
[(2, 2), (3, 3), (2, 2)] [(2, 2), (2, 2)]
>>> print(all(np.allclose(H, H0) for H, H0 in zip(centers, variations[1])))
True
>>> X = x.to_dense()
>>> X1 = np.moveaxis(X, 1, 0).reshape(6, -1)                        # the mode-1 matricization
>>> s_tucker = np.linalg.svd(tucker_factors_T[1], compute_uv=False)
>>> print(np.allclose(s_tucker, np.linalg.svd(X1, compute_uv=False)[:3]))
True
>>> s_bond = np.linalg.svd(bond_factors[1], compute_uv=False)       # bond 2: modes (0,1) | (2,)
>>> print(np.allclose(s_bond, np.linalg.svd(X.reshape(30, 7), compute_uv=False)[:2]))
True
Parameters:

frame (t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray]])

Return type:

t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Tuple[NDArray, …], t3toolbox.backend.common.typ.Tuple[NDArray, …], t3toolbox.backend.common.typ.Tuple[NDArray, …]]