TuckerTensorTrain.from_vector#
- static t3toolbox.tucker_tensor_train.TuckerTensorTrain.from_vector(x_flat, shape, tucker_ranks, tt_ranks, stack_shape=())#
def from_vector( x_flat: NDArray, # shape=(data_size,) shape: Sequence[int], # len=d tucker_ranks: Sequence[int], # len=d tt_ranks: Sequence[int], # len=d+1 stack_shape: Sequence[int] = (), # () if unstacked ) -> 'TuckerTensorTrain':
Constructs a TuckerTensorTrain from a 1D vector containing the core entries.
- Parameters:
x_flat (NDArray) – The flattened vector of core entries.
x_flat.shape=(data_size,)shape (Sequence[int]) – Shape of the tensor.
tucker_ranks (Sequence[int]) – Tucker ranks of the tensor.
tt_ranks (Sequence[int]) – TT ranks.
stack_shape (Sequence[int], optional) – Stack shape. Default (
stack_shape=()): No stacking.
- Return type:
See also
- Returns:
T – TuckerTensorTrain constructed from the vector of all core entries.
T.data_size=len(x_flat),T.shape=shape,T.tucker_ranks=tucker_ranks,T.tt_ranks=tt_ranks,T.stack_shape=stack_shape.- Return type:
- Parameters:
x_flat (NDArray)
shape (collections.abc.Sequence[int])
tucker_ranks (collections.abc.Sequence[int])
tt_ranks (collections.abc.Sequence[int])
stack_shape (collections.abc.Sequence[int])
Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.corewise as cw >>> x = t3.TuckerTensorTrain.randn((14,15,16), (4,5,6), (1,3,4,5), stack_shape=(2,3)) >>> x_flat = x.to_vector() >>> x2 = t3.TuckerTensorTrain.from_vector(x_flat, x.shape, x.tucker_ranks, x.tt_ranks, stack_shape=x.stack_shape) >>> print(cw.corewise_norm(cw.corewise_sub(x.data, x2.data))) 0.0