TuckerTensorTrain.randn#
- static t3toolbox.tucker_tensor_train.TuckerTensorTrain.randn(shape, tucker_ranks, tt_ranks, stack_shape=(), use_jax=False)#
def randn( shape: Tuple[int, ...], tucker_ranks: Tuple[int, ...], tt_ranks: Tuple[int, ...], stack_shape: Tuple[int, ...] = (), use_jax: bool = False, ) -> 'TuckerTensorTrain':
Construct a Tucker tensor train with random cores. Core entries are i.i.d. draws from N(0,1).
- Parameters:
shape (Sequence[int]) – Shape of the TuckerTensorTrain.
len(shape)=d.tucker_ranks (Sequence[int], optional) – Tucker ranks.
len(tucker_ranks)=d. Default (tucker_ranks=None): all Tucker ranks equal 1 .tt_ranks (Sequence[int], optional) – TT ranks.
len(tt_ranks)=d+1. Default (tt_ranks=None): all TT ranks equal 1.stack_shape (Sequence[int], optional) – Stack shape. Default (
stack_shape=()): No stacking.use_jax (bool, optional) – Cores are jax arrays if True, and numpy arrays if False. (default:
use_jax=False)
- Returns:
Random TuckerTensorTrain with the desired shape and ranks.
- Return type:
Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> np.random.seed(0) >>> shape = (14, 15, 16) >>> tucker_ranks = (4, 5, 6) >>> tt_ranks = (1, 3, 2, 1) >>> stack_shape = (2, 3) >>> x = t3.TuckerTensorTrain.randn(shape, tucker_ranks, tt_ranks, stack_shape=stack_shape) # random cores >>> print(x.structure == (shape, tucker_ranks, tt_ranks, stack_shape)) True >>> print(np.any(x.tucker_cores[0] != 0.0)) # cores are filled with N(0,1) draws, not zeros True