TuckerTensorTrain.resize#

t3toolbox.tucker_tensor_train.TuckerTensorTrain.resize(new_shape, new_tucker_ranks, new_tt_ranks)#
def resize(
        self,
        new_shape: Sequence[int], # len=d
        new_tucker_ranks: Sequence[int], # len=d
        new_tt_ranks: Sequence[int], # len=d+1
) -> 'TuckerTensorTrain':

Change shape and ranks by resizing cores. Makes cores bigger via zero padding. Makes cores smaller via truncation.

Returns:

Tucker tensor train with cores resized so that shape=new_shape, tucker_ranks=new_tucker_ranks, tt_ranks=new_tt_ranks.

Return type:

TuckerTensorTrain

Parameters:
  • new_shape (collections.abc.Sequence[int])

  • new_tucker_ranks (collections.abc.Sequence[int])

  • new_tt_ranks (collections.abc.Sequence[int])

Examples

>>> import numpy as np
>>> import t3toolbox.tucker_tensor_train as t3
>>> x = t3.TuckerTensorTrain.randn((14,15,16), (4,6,5), (1,3,2,1))
>>> padded_x = x.resize((17,18,17), (8,8,8), (1,5,6,1))
>>> print(padded_x.structure)
((17, 18, 17), (8, 8, 8), (1, 5, 6, 1), ())

Example where first and last ranks are nonzero:

>>> import numpy as np
>>> import t3toolbox.tucker_tensor_train as t3
>>> x = t3.TuckerTensorTrain.randn((14,15,16), (4,6,5), (3,3,2,4))
>>> padded_x = x.resize((17,18,17), (8,8,8), (5,5,6,7))
>>> print(padded_x.structure)
((17, 18, 17), (8, 8, 8), (5, 5, 6, 7), ())