tltorch.TTMatrix

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

Tensorized Matrix in the Tensor-Train Matrix (MPO) Form

Attributes
decomposition

Methods

from_matrix(matrix, tensorized_row_shape, …)

Create a Tensorized Matrix by tensorizing and decomposing an existing matrix

new(tensorized_row_shape, …[, n_matrices])

Main way to create a Tensorized Matrix

normal_([mean, std])

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

to_matrix()

Reconstruct the full matrix from the factorized tensorization

to_tensor()

Reconstruct the full tensor from its factorized form

from_tensor

init_from_matrix

init_from_tensor

classmethod new(tensorized_row_shape, tensorized_column_shape, rank, n_matrices=(), **kwargs)[source]

Main way to create a Tensorized Matrix

Parameters
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.

classmethod from_matrix(matrix, tensorized_row_shape, tensorized_column_shape, rank, **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.

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
to_matrix()[source]

Reconstruct the full matrix from the factorized tensorization

If several matrices are parametrized, a batch of matrices is returned