TuckerTensorTrain.apply_ambient_transpose#

static t3toolbox.tucker_tensor_train.TuckerTensorTrain.apply_ambient_transpose(c, ww, sum_over_probes=False)#
def apply_ambient_transpose(
        c:      NDArray,            # residual, shape = W + C
        ww:     Sequence[NDArray],  # apply vectors, len=d, elm_shape = W + (Ni,)
        sum_over_probes: bool = False,
) -> Sequence[NDArray]:            # canonical (CP) factors, len=d, elm_shape = stack + (R, Ni)

Ambient transpose of apply(): back-project c into canonical (CP) factors.

This is one of three transposes of apply – make sure it is the one you want (full taxonomy and costs in docs/transposes.md):

  • ambient (this method): the literal adjoint of apply viewed as a linear map on the full tensor space. Frame-free; the back-projection c * (w0 (x) ... (x) w_{d-1}) is rank-1, returned as CP factors – the natural type, since apply consumes one vector per mode and its adjoint emits one scaled vector per mode. Convert to a TuckerTensorTrain with from_canonical() if you want T3 form.

  • corewise (apply_corewise_transpose): the gradient w.r.t. a base point’s cores, for core-wise optimizers (Adam, L-BFGS). Most users who reach for “the transpose to get a gradient” actually want this – hence the explicit names, so neither is the silent default.

  • tangent (T3Tangent.apply_transpose): the Riemannian gradient, returned as a tangent vector, for manifold optimization.

sum_over_probes chooses where the probe stack W lands (both modes are cheap, O(d|W|N)):

  • False (default, primary): W is a passthrough stacking axis – a W (+ C) stack of rank-1 CP tensors (CP rank R=1), one back-projection per probe.

  • True: W becomes the CP rank – one rank-|W| CP tensor sum_W c_W (w0^W (x) ...) (the ambient J^T r). Cheap as CP; the |W|^2 cost of a dense T3 is paid only if you then call from_canonical().

Returns the CP factors (c folded into the first), in the layout from_canonical() consumes. See Batching & stacking §11 (docs/batching_and_stacking.md) for the stacking conventions.

Examples

Adjoint identity <apply_ambient_transpose(c, ww), x>_F == c * x.apply(ww) – realize the CP factors as a T3 with from_canonical():

>>> import numpy as np
>>> import t3toolbox.tucker_tensor_train as t3
>>> x = t3.TuckerTensorTrain.randn((10, 11, 12), (5, 6, 4), (1, 2, 3, 1))
>>> ww = (np.random.randn(10), np.random.randn(11), np.random.randn(12))
>>> factors = t3.TuckerTensorTrain.apply_ambient_transpose(1.7, ww)
>>> ATc = t3.TuckerTensorTrain.from_canonical(factors)     # CP factors -> a TuckerTensorTrain
>>> lhs = float(np.sum(ATc.to_dense() * x.to_dense()))
>>> print(bool(abs(lhs - 1.7 * float(x.apply(ww))) < 1e-9))
True
Parameters:
  • c (NDArray)

  • ww (collections.abc.Sequence[NDArray])

  • sum_over_probes (bool)

Return type:

collections.abc.Sequence[NDArray]