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-projectcinto canonical (CP) factors.This is one of three transposes of
apply– make sure it is the one you want (full taxonomy and costs indocs/transposes.md):ambient (this method): the literal adjoint of
applyviewed as a linear map on the full tensor space. Frame-free; the back-projectionc * (w0 (x) ... (x) w_{d-1})is rank-1, returned as CP factors – the natural type, sinceapplyconsumes one vector per mode and its adjoint emits one scaled vector per mode. Convert to aTuckerTensorTrainwithfrom_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_probeschooses where the probe stackWlands (both modes are cheap,O(d|W|N)):False(default, primary):Wis a passthrough stacking axis – aW (+ C)stack of rank-1 CP tensors (CP rankR=1), one back-projection per probe.True:Wbecomes the CP rank – one rank-|W|CP tensorsum_W c_W (w0^W (x) ...)(the ambientJ^T r). Cheap as CP; the|W|^2cost of a dense T3 is paid only if you then callfrom_canonical().
Returns the CP
factors(cfolded into the first), in the layoutfrom_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 withfrom_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