tltorch
.TensorizedTensor¶
- class tltorch.TensorizedTensor(*args, **kwargs)[source]¶
Matrix in Tensorized Format
Important
order and tensorized_shape correspond to the underlying tensor
shape, dim and ndim correspond to the matrix
- Attributes:
- tensor_shape
Methods
from_matrix
(matrix, tensorized_row_shape, ...)Create a Tensorized Matrix by tensorizing and decomposing an existing matrix
from_tensor
(tensor, shape, rank[, factorization])Create a factorized tensor by decomposing a full tensor
new
(tensorized_shape, rank[, factorization])Main way to create a Tensorized Matrix
Reconstruct the full matrix from the factorized tensorization
init_from_matrix
- classmethod new(tensorized_shape, rank, factorization='CP', **kwargs)[source]¶
Main way to create a Tensorized Matrix
- Parameters:
- tensorized_shapetuple[int]
- rankint, ‘same’ or float
rank of the decomposition
- n_matricestuple or int, default is ()
if not (), indicates how many matrices have to be jointly factorized
- factorization{‘CP’, ‘TT’, ‘Tucker’}, optional
Tensor factorization to use to decompose the tensor, by default ‘CP’
- Returns:
- TensorizedTensor
Tensor in Tensorized and Factorized form.
- Raises:
- ValueError
If the factorization given does not exist.
- classmethod from_tensor(tensor, shape, rank, factorization='CP', **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.
- classmethod from_matrix(matrix, tensorized_row_shape, tensorized_column_shape, rank, factorization='CP', **kwargs)[source]¶
Create a Tensorized Matrix by tensorizing and decomposing an existing matrix
- Parameters:
- matrixtorch.tensor of order 2
matrix to decompose
- tensorized_row_shapetuple[int]
The first dimension (rows) of the matrix will be tensorized to that shape
- tensorized_column_shapetuple[int]
The second dimension (columns) of the matrix will be tensorized to that shape
- rankint, ‘same’ or float
rank of the decomposition
- n_matricestuple or int, default is ()
if not (), indicates how many matrices have to be jointly factorized
- factorization{‘CP’, ‘TT’, ‘Tucker’}, optional
Tensor factorization to use to decompose the tensor, by default ‘CP’
- Returns:
- TensorizedMatrix
Matrix in Tensorized and Factorized form.
- Raises:
- ValueError
If the factorization given does not exist.