# Import statement
from hottbox.core import TensorTT
TensorTT
(core_values, mode_names=None)[source]¶Representation of a tensor in the Tensor Train form (TT).
List of cores for the Tensor Train representation of a tensor.
List of names for the physical modes
Attributes
_core_values |
(list[np.ndarray]) Placeholder for a list of cores for the Tensor Train representation of a tensor. |
_modes |
(list[Mode]) Description of the physical modes |
If there is inconsistency in shapes of core values
Examples
Create tensor train representation of a tensor with default meta information
>>> import numpy as np
>>> from hottbox.core import TensorTT
>>> I, J, K = 5, 6, 7 # shape of the tensor in full form
>>> R_1, R_2 = 3, 4 # tt-rank
>>> core_0 = np.ones((I, R_1))
>>> core_1 = np.ones((R1, J, R2))
>>> core_2 = np.ones((R2, K))
>>> core_values = [core_0, core_1, core_2]
>>> tensor_tt = TensorTT(core_values)
>>> print(tensor_tt)
Tensor train representation of a tensor with tt-rank=(3, 4).
Shape of this representation in the full format is (5, 6, 7).
Physical modes of its cores represent properties: ['mode-0', 'mode-1', 'mode-2']
Create tensor train representation of a tensor with custom meta information
>>> import numpy as np
>>> from hottbox.core import TensorTT
>>> I, J, K = 5, 6, 7 # shape of the tensor in full form
>>> R_1, R_2 = 3, 4 # tt-rank
>>> core_0 = np.ones((I, R_1))
>>> core_1 = np.ones((R_1, J, R_2))
>>> core_2 = np.ones((R_2, K))
>>> core_values = [core_0, core_1, core_2]
>>> mode_names = ["Year", "Month", "Day"]
>>> tensor_tt = TensorTT(core_values, mode_names)
>>> print(tensor_tt)
Tensor train representation of a tensor with tt-rank=(3, 4).
Shape of this representation in the full format is (5, 6, 7).
Physical modes of its cores represent properties: ['Year', 'Month', 'Day']
Methods
|
Produces a copy of itself as a new object |
|
Copy modes meta from tensor |
|
Specific core of the TensorTT representation |
|
Converts the TT representation of a tensor into a full tensor |
|
Drop index for the specified mode number |
|
Set default name for the specified mode number |
|
Set index for specified mode |
|
Rename modes of a tensor representation |
copy_modes
(self, tensor)[source]¶Copy modes meta from tensor
Notes
Most of the time this method should only be used by the decomposition algorithms
core
(self, i)[source]¶Specific core of the TensorTT representation
Should not exceed the order of TensorTT.order
representation
cores
¶All cores of the TensorTT representation
ft_shape
¶Shape of a TensorTT
in the full format
mode_names
¶Description of the physical modes for a TensorTT
modes
¶Meta data for the factor matrices
order
¶Order of a tensor represented through the TT
rank
¶Rank of the TT representation of a tensor
Notes
Most often referred to as the TT rank
reconstruct
(self, keep_meta=0)[source]¶Converts the TT representation of a tensor into a full tensor
Keep meta information about modes of the given tensor. 0 - the output will have default values for the meta data 1 - keep only mode names 2 - keep mode names and indices
reset_mode_index
(self, mode=None)[source]¶Drop index for the specified mode number
Mode number which index to be dropped By default resets all indices
reset_mode_name
(self, mode=None)[source]¶Set default name for the specified mode number
Mode number which name to be set to default value By default resets names of all modes