fv_zero_point_frame#
- t3toolbox.backend.fv_operations.fv_zero_point_frame(frame, groups=(), seed=ZERO_FRAME_SEED)#
def fv_zero_point_frame( frame: typ.Tuple[ typ.Sequence[NDArray], # down_tucker_cores. len=d, elm_shape=(nDi, Ni) typ.Sequence[NDArray], # up_tt_cores. len=d, elm_shape=(rLi, nUi, rR(i+1)) typ.Sequence[NDArray], # left_tt_cores. len=d, elm_shape=(rLi, nDi, rL(i+1)) typ.Sequence[NDArray], # right_tt_cores. len=d, elm_shape=(rRi, nDi, rR(i+1)) ], groups: typ.Tuple[typ.Tuple[int, ...], ...] = (), # sharing partition (canonical_groups); () = unshared seed: int = ZERO_FRAME_SEED, # the Haar stream seed: a fixed convention ) -> typ.Tuple[ typ.Tuple[NDArray, ...], # down: seeded Haar rows, one draw per group. len=d, elm_shape=(nDi, Ni) typ.Tuple[NDArray, ...], # up: identity-prefix, orthonormal. len=d, elm_shape=(rLi, nUi, rR(i+1)) typ.Tuple[NDArray, ...], # left: identity-prefix, left-orthogonal; L[d-1] = 0 typ.Tuple[NDArray, ...], # right: identity-prefix, right-orthogonal; R[0] = 0 ]:
The canonical orthonormal frame at the zero tensor, with
frame’s structure (its core shapes).At
X = 0every orthonormal completion is a valid frame, and the Riemannian gradient’s norm there depends on which one is chosen. This function fixes the choice by a convention, so that the zero-tensor gradient norm – the default Newton reference ofbackend.optimizers.newton_cg(g0_reference='zero') – is a deterministic number. Only the frame’s shapes are read; its values are not, so any frame with the right ranks gives the same result.The construction:
Tucker factors (
down): per sharing groupg(an unshared mode is its own group), with keyk_g = min(g), drawG = RandomState([seed, k_g]).standard_normal((n_g, N_g)), take the sign-fixed reduced QR ofG.T, and setD_g = Q.T: Haar-distributed orthonormal rows, the same array for every mode of the group.TT cores (
up/left/right): identity prefixes – exactly orthonormal, no draw – withleft[d-1] = right[0] = 0, so both base-point reconstructions are the zero tensor.
Three properties follow, and are what the reference relies on:
Rank independence. Each group draws from its own keyed stream, so changing one mode’s rank or size leaves every other mode’s factor bit-identical.
Nesting. QR column
jdepends only on draw rows<= j, so the factor at rankris the leadingr-row block of the factor at rankr + 1: across rank-continuation levels the reference frames are nested subspaces.Layer independence. The uniform twin (
ufv_zero_point_frame()) builds the same real blocks, so the reference is identical on the ragged and uniform layers.
Why Haar, and only for the Tucker factors. The Tucker factor is the only part of the frame that meets the data. A coordinate-aligned factor (an identity prefix, or LAPACK’s completion of a zero core) gives a reference of exactly zero whenever the data have no energy on its leading coordinates; a Haar factor is generic. The TT cores act on rank indices, which carry no data orientation. The seed is a convention, not a parameter worth tuning: another seed moves the reference by an O(1) factor, which is harmless for a relative stopping test.
RandomState’s legacy stream is frozen across numpy versions; the QR is reproducible to ~1e-15 across BLAS builds.The result has the template’s dtype and backend (numpy or jax, inferred). The draws themselves are host numpy by design – a convention, not data. A stacked template (stack
C != ()) raisesNotImplementedError: the zero-point frame exists for the optimizers’ reference, and the optimizers take an unstacked point (backend.optimizers._require_unstacked).Examples
The zero-point frame of a rank-
(2, 3, 2)structure is orthonormal, sits at the zero tensor, and copies the template’s core shapes:>>> 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 >>> import t3toolbox.backend.t3_conversions as t3c >>> def structure(tucker_ranks, tt_ranks): # any frame with these ranks; only its shapes are read ... x = t3.TuckerTensorTrain.zeros((5, 6, 7), tucker_ranks, tt_ranks) ... return fvc.t3_orthogonal_representations(x.data)[0] >>> template = structure((2, 3, 2), (1, 2, 2, 1)) >>> down, up, left, right = fvo.fv_zero_point_frame(template) >>> print([u.shape for u in down], [g.shape for g in left]) [(2, 5), (3, 6), (2, 7)] [(1, 2, 2), (2, 3, 2), (2, 2, 1)] >>> bool(fvo.fv_frame_orthogonality_residual((down, up, left, right)) < 1e-14) True >>> print(float(np.abs(t3c.t3_to_dense((down, left))).max())) # the base point is the zero tensor 0.0
Nested across ranks, and independent of the other modes’ ranks:
>>> down_more = fvo.fv_zero_point_frame(structure((3, 3, 2), (1, 3, 2, 1)))[0] >>> bool(np.allclose(down_more[0][:2], down[0])) # mode 0 at rank 3 extends mode 0 at rank 2 True >>> bool(np.array_equal(down_more[2], down[2])) # mode 2 is untouched by mode 0's rank True
With sharing, one factor per group:
>>> template = fvc.t3_orthogonal_representations( ... t3.TuckerTensorTrain.zeros((6, 6, 7), (3, 3, 2), (1, 3, 2, 1)).data)[0] >>> down_shared = fvo.fv_zero_point_frame(template, groups=((0, 1), (2,)))[0] >>> bool(np.array_equal(down_shared[0], down_shared[1])) 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]])
groups (t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Tuple[int, ...], ...])
seed (int)
- 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, …], t3toolbox.backend.common.typ.Tuple[NDArray, …]]