UT3Variations#
- class t3toolbox.uniform_frame_variations_format.UT3Variations#
Variation cores for the frame-variations representation of uniform Tucker tensor trains.
Uniform analog of
T3Variations: two padded supercores (tucker_variations,tt_variations) + the static physicalshape(an int tuple, shared across the stack) + aUT3VariationsMasksholder. The variations fit in the “holes” of aUT3Frame.Examples
>>> import numpy as np >>> import t3toolbox.uniform_frame_variations_format as ubcf >>> d, N, nU, nD, rL, rR = 3, 6, 4, 5, 3, 2 >>> tkv = np.random.randn(d, nD, N) >>> ttv = np.random.randn(d, rL, nU, rR) >>> shape = (4, 5, 6) >>> up = np.arange(nU) < np.array([[2],[3],[4]]) # (d, nU) >>> down = np.arange(nD) < np.array([[3],[4],[5]]) # (d, nD) >>> left = np.arange(rL) < np.array([[1],[2],[3]]) # (d, rL) -- note d, not d+1 >>> right = np.arange(rR) < np.array([[1],[2],[2]]) # (d, rR) >>> masks = ubcf.UT3VariationsMasks(up, down, left, right) >>> V = ubcf.UT3Variations(tkv, ttv, shape, masks) >>> V.uniform_structure (3, 6, 4, 5, 3, 2, ()) >>> V.uniform_variation_shapes ((3, 5, 6), (3, 3, 4, 2))
- shape: t3toolbox.backend.common.typ.Tuple[int, Ellipsis]#
- masks: UT3VariationsMasks#
- __rmul__#
Methods#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Apply masks to the variation supercores, zeroing out unmasked entries. |
|
|
Pack a ragged |
Convert to ragged |
|
The two padded supercores |
|
True if any supercore is a jax array (the masks are always host numpy). |
|
|
|
|
|
|
|
|
|
|
Check rank and shape consistency of a uniform Tucker tensor train variations (UT3Variations). |
|
Unstack a stacked UT3Variations into an array-like tree (shaped like |
|
Stack an array-like tree of UT3Variations into a single stacked UT3Variations. |
|
Corewise sum (variations form a vector space at a fixed frame; the mask is unchanged). |
|
Corewise difference (mask unchanged). |
|
Corewise scalar multiplication (mask unchanged). |
|
Corewise negation (mask unchanged). |
|
Reverse the mode order (corewise): the tucker-variation supercore reverses; the tt-variation |
|
Save the two supercores + |
|
Load variations saved by |
|
Corewise sum over stack axes (a batch of variations -> their sum; the tangent sum, by linearity). |
|
|
|
Zero variations filling the padded supercores completely (additive identity). |
|
Variations with i.i.d. N(0,1) supercore entries (filled completely; ungauged). See |
|
Canonical unit variation: zero supercores except a single entry set to 1 (broadcast over the |
|
Zero variations matching the structure of |
|
Random variations matching the structure (incl. gauge masks) of |