tltorch.TuckerTensor

class tltorch.TuckerTensor(*args, **kwargs)[source]

Tucker Factorization

Parameters
core
factors
shape
rank
Attributes
decomposition

Methods

from_tensor(tensor[, rank, fixed_rank_modes])

Create a factorized tensor by decomposing a full tensor

init_from_tensor(tensor[, unsqueezed_modes, …])

Initialize the tensor factorization from a tensor

new(shape, rank[, fixed_rank_modes])

Main way to create a factorized tensor

normal_([mean, std])

Inialize the factors of the factorization such that the reconstruction follows a Gaussian distribution

to_tensor()

Reconstruct the full tensor from its factorized form

classmethod new(shape, rank, fixed_rank_modes=None, **kwargs)[source]

Main way to create a factorized tensor

Parameters
shapetuple[int]

shape of the factorized tensor to create

rankint, ‘same’ or float

rank of the decomposition

factorization{‘CP’, ‘TT’, ‘Tucker’}, optional

Tensor factorization to use to decompose the tensor, by default ‘CP’

Returns
TensorFactorization

Tensor in Factorized form.

Raises
ValueError

If the factorization given does not exist.

classmethod from_tensor(tensor, rank='same', fixed_rank_modes=None, **kwargs)[source]

Create a factorized tensor by decomposing a full tensor

Parameters
tensortorch.tensor

tensor to factorize

shapetuple[int]

shape of the factorized tensor to create

rankint, ‘same’ or float

rank of the decomposition

factorization{‘CP’, ‘TT’, ‘Tucker’}, optional

Tensor factorization to use to decompose the tensor, by default ‘CP’

Returns
TensorFactorization

Tensor in Factorized form.

Raises
ValueError

If the factorization given does not exist.

init_from_tensor(tensor, unsqueezed_modes=None, unsqueezed_init='average', **kwargs)[source]

Initialize the tensor factorization from a tensor

Parameters
tensortorch.Tensor

full tensor to decompose

unsqueezed_modesint list

list of modes for which the rank is 1 that don’t correspond to a mode in the full tensor essentially we are adding a new dimension for which the core has dim 1, and that is not initialized through decomposition. Instead first tensor is decomposed into the other factors. The unsqueezed factors are then added and initialized e.g. with 1/dim[i]

unsqueezed_init‘average’ or float

if unsqueezed_modes, this is how the added “unsqueezed” factors will be initialized if ‘average’, then unsqueezed_factor[i] will have value 1/tensor.shape[i]

to_tensor()[source]

Reconstruct the full tensor from its factorized form

normal_(mean=0, std=1)[source]

Inialize the factors of the factorization such that the reconstruction follows a Gaussian distribution

Parameters
meanfloat, currently only 0 is supported
stdfloat

standard deviation

Returns
self