TensorLearn
TensorLearn is a Python library distributed on Pypi to implement tensor learning methods.
This is a project under development. Yet, the available methods are final and functional.
Installation
Use the package manager pip to install tensorlearn in Python.
pip install tensorlearn
methods
Decomposition Methods
Tensor Operations for Tensor-Train
Tensor Operations for CANDECOMP/PARAFAC (CP)
Tensor Operations
Matrix Operations
auto_rank_tt
tensorlearn.auto_rank_tt(tensor, epsilon)
This implementation of tensor-train decomposition determines the ranks automatically based on a given error bound according to Oseledets (2011). Therefore the user does not need to specify the ranks. Instead the user specifies an upper error bound (epsilon) which bounds the error of the decomposition. For more information and details please see the page tensor-train decomposition.
Arguments
-
tensor < array >: The given tensor to be decomposed.
-
epsilon < float >: The error bound of decomposition in the range [0,1].
Return
- TT factors < list of arrays >: The list includes numpy arrays of factors (or TT cores) according to TT decomposition. Length of the list equals the dimension of the given tensor to be decomposed.
cp_als_rand_init
tensorlearn.cp_als_rand_init(tensor, rank, iteration, random_seed=None)
This is an implementation of CANDECOMP/PARAFAC (CP) decomposition using alternating least squares (ALS) algorithm with random initialization of factors.
Arguments
-
tensor < array >: the given tensor to be decomposed
-
rank < int >: number of ranks
-
iterations < int >: the number of iterations of the ALS algorithm
-
random_seed < int >: the seed of random number generator for random initialization of the factor matrices
Return
-
weights < array >: the vector of normalization weights (lambda) in CP decomposition
-
factors < list of arrays >: factor matrices of the CP decomposition
tt_to_tensor
tensorlearn.tt_to_tensor(factors)
Returns the full tensor given the TT factors
Arguments
- factors < list of numpy arrays >: TT factors
Return
- full tensor < numpy array >
tt_compression_ratio
tensorlearn.tt_compression_ratio(factors)
Returns data compression ratio for tensor-train decompostion
Arguments
- factors < list of numpy arrays >: TT factors
Return
- Compression ratio < float >
cp_to_tensor
Returns the full tensor given the CP factor matrices and weights
tensorlearn.cp_to_tensor(weights, factors)
Arguments
-
weights < array >: the vector of normalization weights (lambda) in CP decomposition
-
factors < list of arrays >: factor matrices of the CP decomposition
Return
- full tensor < array >
cp_compression_ratio
Returns data compression ratio for CP- decompostion
tensorlearn.cp_compression_ratio(weights, factors)
Arguments
-
weights < array >: the vector of normalization weights (lambda) in CP decomposition
-
factors < list of arrays >: factor matrices of the CP decomposition
Return
- Compression ratio < float >
tensor_resize
tensorlearn.tensor_resize(tensor, new_shape)
This method reshapes the given tensor to a new shape. The new size must be bigger than or equal to the original shape. If the new shape results in a tensor of greater size (number of elements) the tensor fills with zeros. This works similar to numpy.ndarray.resize()
Arguments
-
tensor < array >: the given tensor
-
new_shape < tuple >: new shape
Return
- tensor < array >: tensor with new given shape
unfold
tensorlearn.unfold(tensor, n)
Unfold the tensor with respect to dimension n.
Arguments
-
tensor < array >: tensor to be unfolded
-
n < int >: dimension based on which the tensor is unfolded
Return
- matrix < array >: unfolded tensor with respect to dimension n
tensor_frobenius_norm
tensorlearn.tensor_frobenius_norm(tensor)
Calculates the frobenius norm of the given tensor.
Arguments
- tensor < array >: the given tensor
Return
- frobenius norm < float >
error_truncated_svd
tensorlearn.error_truncated_svd(x, error)
This method conducts a compact svd and return sigma (error)-truncated SVD of a given matrix. This is an implementation using numpy.linalg.svd with full_matrices=False. This method is used in TT-SVD algorithm in auto_rank_tt.
Arguments
-
x < 2D array >: the given matrix to be decomposed
-
error < float >: the given error in the range [0,1]
Return
- r, u, s, vh < int, numpy array, numpy array, numpy array >
column_wise_kronecker
tensorlearn.column_wise_kronecker(a, b)
Returns the column wise Kronecker product (Sometimes known as Khatri Rao) of two given matrices.
Arguments
- a,b < 2D array >: the given matrices
Return
- column wise Kronecker product < array >
Metadata
Release files for tensorlearn 1.1.24
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tensorlearn-1.1.24.tar.gz | 19.5 kB | Without provenance | Details for tensorlearn-1.1.24.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tensorlearn-1.1.24-py3-none-any.whl | Python 3 | none | any | Details for tensorlearn-1.1.24-py3-none-any.whl |
Total release size: 44.2 kB
Release files / tensorlearn-1.1.24.tar.gz
| Download URL | tensorlearn-1.1.24.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e710fd568390d1b8be508e0f084e385a7fb0064a20eee14d0c790e34b824811
|
|
BLAKE2b-256 checksum How to use checksums |
a6376e2454a876b70b75136c8d7a2c1efe6af633c5d5639ef0c6783524f36380
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / tensorlearn-1.1.24-py3-none-any.whl
| Download URL | tensorlearn-1.1.24-py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8124a4db979bc80f8bbc5800270da49f02b6bed4416e91a87bccc2e8bcd7621
|
|
BLAKE2b-256 checksum How to use checksums |
5fb3cf26e759aa7c788127e1b44505e1df875994c0b6b9fca938dc8e80e8f830
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for tensorlearn 1.1.24
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.