T3Weights#

class t3toolbox.tucker_tensor_train.T3Weights#

Diagonal weights on the internal edges of a TuckerTensorTrain – one vector per edge.

A weight is a diagonal matrix inserted on a network edge (stored as its diagonal vector). Two edge families: Tucker-rank edges nᵢ (between each Tucker factor and its TT core, len=d) and TT-bond edges rᵢ (between neighbouring TT cores, len=d+1, ends r₀=r_d=1). The represented tensor is absorb_weights(x, W).to_dense(); the plain (unweighted) network norm squares the inserted diagonal, so diag(1/σ) penalises by 1/σ². Batching mirrors TuckerTensorTrain: every vector is stack_shape + (rank,) (the frame/core stack C); one object holds a stack of weights.

Examples

>>> import numpy as np
>>> import t3toolbox.tucker_tensor_train as t3
>>> np.random.seed(0)
>>> x = t3.TuckerTensorTrain.randn((6, 7, 8), (2, 2, 2), (1, 2, 2, 1))   # minimal ranks
>>> W = t3.T3Weights.from_t3svd(x)          # the singular values are the canonical weight object
>>> print(W.tucker_ranks, W.tt_ranks)
(2, 2, 2) (1, 2, 2, 1)
>>> print(W.is_consistent_with(x))
True
>>> xw = t3.t3_absorb_weights(x, W)            # shape-preserving; ranks unchanged
>>> print(xw.ranks == x.ranks)
True
tucker_weights: Tuple[NDArray, Ellipsis]#
tt_weights: Tuple[NDArray, Ellipsis]#
property data: Tuple[Tuple[NDArray, Ellipsis], Tuple[NDArray, Ellipsis]]#
Return type:

Tuple[Tuple[NDArray, Ellipsis], Tuple[NDArray, Ellipsis]]

property d: int#
Return type:

int

property tucker_ranks: Tuple[int, Ellipsis]#
Return type:

Tuple[int, Ellipsis]

property tt_ranks: Tuple[int, Ellipsis]#
Return type:

Tuple[int, Ellipsis]

property stack_shape: Tuple[int, Ellipsis]#
Return type:

Tuple[int, Ellipsis]

Methods#

validate()

Structural consistency: lengths (d / d+1) and a uniform stack_shape on every vector.

__post_init__()

is_consistent_with(x)

True iff these weights' ranks + stack_shape match the TuckerTensorTrain x (non-raising).

reciprocal()

Elementwise 1/w on every edge (e.g. to form inverse-singular-value weights).

sqrt()

Elementwise sqrt on every edge.

reverse()

Reverse the mode order (reverses both edge-vector tuples), matching TuckerTensorTrain.reverse.

concatenate(other)

Per-edge concatenation with other -- the + / direct-sum combine (ranks add).

kronecker(other)

Per-edge Kronecker product with other -- the Hadamard (elementwise-product) combine (ranks

unstack()

Unstack a stack of weights into an array-like tree (mirrors TuckerTensorTrain.unstack).

stack(xx)

Stack an array-like tree of T3Weights into one (mirrors TuckerTensorTrain.stack).

from_t3svd(x, **kwargs)

The singular values of x as a weight object -- the canonical (unmodified) σ's, so