TuckerTensorTrain.stack#
- static t3toolbox.tucker_tensor_train.TuckerTensorTrain.stack(xx)#
def stack( xx, # array-like structure of nested tuples containing TuckerTensorTrains ) -> 'TuckerTensorTrain': # (stacked_tucker_cores, stacked_tt_cores)
Stacks an array-like tree of TuckerTensorTrains into one stacked TuckerTensorTrain.
- Parameters:
xx (Array-like tree of nested tuples with TuckerTensorTrain leafs) – TuckerTensorTrains to be stacked. All TuckerTensorTrains must have the same shape and ranks.
- Returns:
Stacked TuckerTensorTrain.
- Return type:
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,6,2), (1,4,2,1), stack_shape=(3,5)) >>> xx = x.unstack() >>> print(len(xx)) 3 >>> print(len(xx[0])) 5 >>> x2 = t3.TuckerTensorTrain.stack(xx) >>> print(cw.corewise_norm(cw.corewise_sub(x.data, x2.data))) 0.0