tltorch
.DenseTensor¶
- class tltorch.DenseTensor(*args, **kwargs)[source]¶
Dense tensor
- Attributes:
decomposition
Returns the factors and parameters composing the tensor in factorized form
Methods
from_tensor
(tensor[, rank])Create a factorized tensor by decomposing a dense tensor
new
(shape[, rank, device, dtype])Main way to create a factorized tensor
normal_
([mean, std])Inialize the factors of the factorization such that the reconstruction follows a Gaussian distribution
Reconstruct the full tensor from its factorized form
init_from_tensor
- classmethod new(shape, rank=None, device=None, dtype=None, **kwargs)[source]¶
Main way to create a factorized tensor
- Parameters:
- shapetuple[int]
shape of the factorized tensor to create
- rankint, ‘same’ or float, default is ‘same’
rank of the decomposition
- factorization{‘CP’, ‘TT’, ‘Tucker’}, optional
Tensor factorization to use to decompose the tensor, by default ‘Tucker’
- Returns:
- TensorFactorization
Tensor in Factorized form.
- Raises:
- ValueError
If the factorization given does not exist.
Examples
Create a Tucker tensor of shape (3, 4, 2) with half the parameters as a dense tensor would:
>>> tucker_tensor = FactorizedTensor.new((3, 4, 2)), rank=0.5, factorization='tucker')
- classmethod from_tensor(tensor, rank='same', **kwargs)[source]¶
Create a factorized tensor by decomposing a dense tensor
- Parameters:
- tensortorch.tensor
tensor to factorize
- 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.
- property decomposition¶
Returns the factors and parameters composing the tensor in factorized form