Skip to main content

A Python Package for Advanced Tensor Learning Methods

Project description

TensorLearn

TensorLearn is a Python library distributed on Pypi for implementing tensor learning methods.

This is a package under development. Yet, the available methods are final and functional. The backend is Numpy.

Installation

Use the package manager pip to install tensorlearn in Python.

pip install tensorlearn

methods

Decomposition Methods

Tensor Operations for Tensor-Train

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 < numpy array > - The given tensor to be decomposed.

@epsilon < float > - The error bound of decomposition in the range [0,1].

Return

TT factors < list of numpy 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.

Example


tt_to_tensor

tensorlearn.tt_to_tensor(factors)

Return the full tensor given the TT factors

Arguments

@factors < list of numpy arrays > - TT factors

Return

full tensor < numpy array >

Example


tt_compression_ratio

tensorlearn.tt_compression_ratio(factors)

Calculate data compression ratio for tensor-train decompostion

Arguments

@factors < list of numpy arrays > - TT factors

Return

Compression ratio < float >

Example


tensor_resize

tensorlearn.tensor_resize(tensor, new_shape)

Reshape 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 < numpy array > - the given tensor

@new_shape < tuple > - new shape

Return

tensor < numpy array > - tensor with new given shape


unfold

tensorlearn.unfold(tensor, n)

Unfold the tensor with respect to dimension n.

Arguments

@tensor < numpy array > - tensor to be unfolded

@n < int > - dimension based on which the tensor is unfolded

Return

matrix < numpy array > - unfolded tensor with respect to dimension n


tensor_frobenius_norm

tensorlearn.tensor_frobenius_norm(tensor)

Calculate the frobenius norm of the given tensor.

Arguments

@tensor < numpy array > - the given tensor

Return

frobenius norm < float >

Example


error_truncated_svd

tensorlearn.error_truncated_svd(x, error)

Conduct 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 numpy 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 >

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorlearn-1.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

tensorlearn-1.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file tensorlearn-1.1.0.tar.gz.

File metadata

  • Download URL: tensorlearn-1.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.8

File hashes

Hashes for tensorlearn-1.1.0.tar.gz
Algorithm Hash digest
SHA256 da99af797f26b168e64d58fa28b663783194c2b07b768083984c7f00c7c4a58d
MD5 dac76e64b8fafc39cc0ab192bf3c95bf
BLAKE2b-256 ece8671dded7f2dc69389ddb4ecc3de7f8f975d85011770ee54e6109ccf17c17

See more details on using hashes here.

File details

Details for the file tensorlearn-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tensorlearn-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.8

File hashes

Hashes for tensorlearn-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11046821b991f16bdaee7c2fdc94afd5a323a9c6eff36e037bc43fc025777813
MD5 d3bca32b4a0dcbb6706d66fff5a68184
BLAKE2b-256 6afd6bd4f9ed682c303530b2dcae03078384e6fa7c71b8e3ab46f2ef8bd289d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page