TuckerTensorTrain.ones#
- static t3toolbox.tucker_tensor_train.TuckerTensorTrain.ones(shape, stack_shape=(), use_jax=False)#
def ones( shape: Tuple[int, ...], stack_shape: Tuple[int, ...] = (), use_jax: bool = False, ) -> 'TuckerTensorTrain':
Construct TuckerTensorTrain representation of dense tensor filled with ones. Has Tucker and TT ranks equal to 1.
- Parameters:
shape (Sequence[int]) – Shape of the TuckerTensorTrain.
len(shape)=d.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:
Ones TuckerTensorTrain with the desired shape.
tucker_ranks=(1,...,1)andtt_ranks=(1,...,1)- Return type:
Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> shape = (14, 15, 16) >>> stack_shape = (2,3) >>> x = t3.TuckerTensorTrain.ones(shape, stack_shape=stack_shape) >>> print(np.linalg.norm(x.to_dense() - np.ones(stack_shape+shape))) 0.0 >>> print(x.tucker_ranks) (1, 1, 1) >>> print(x.tt_ranks) (1, 1, 1, 1)