TuckerTensorTrain.to_vector#
- t3toolbox.tucker_tensor_train.TuckerTensorTrain.to_vector()#
def to_vector( self, ) -> NDArray:
Converts a TuckerTensorTrain into a 1D vector containing the core entries.
- Returns:
The vector of all core entries.
shape=(self.data_size,)- Return type:
See also
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