# Import statement
from hottbox.core import TensorTKD
TensorTKD
(fmat, core_values, mode_names=None)[source]¶Representation of a tensor in the Tucker form (TKD).
List of factor matrices for the Tucker representation of a tensor
Core of the Tucker representation of a tensor
List of names for the factor matrices
Attributes
_fmat |
(list[np.ndarray]) Placeholder for a list of factor matrices for the Tucker representation of a tensor |
_core_values |
(np.ndarray) Placeholder for a core of the Tucker representation of a tensor |
_modes |
(list[Mode]) Description of the factor matrix for the corresponding mode |
If there is inconsistency in shapes of factor matrices and core values
Examples
Create tucker representation of a tensor with default meta information
>>> import numpy as np
>>> from hottbox.core import TensorTKD
>>> I, J, K = 5, 6, 7 # shape of the tensor in full form
>>> R_1, R_2, R_3 = 2, 3, 4 # multi-linear rank
>>> A = np.ones((I, R_1))
>>> B = np.ones((J, R_2))
>>> C = np.ones((K, R_3))
>>> fmat = [A, B , C]
>>> core_values = np.ones((R_1, R_2, R_3))
>>> tensor_tkd = TensorTKD(fmat, core_values)
>>> print(tensor_tkd)
Tucker representation of a tensor with multi-linear rank=(2, 3, 4).
Factor matrices represent properties: ['mode-0', 'mode-1', 'mode-2']
With corresponding latent components described by (5, 6, 7) features respectively.
Create tucker representation of a tensor with custom meta information
>>> import numpy as np
>>> from hottbox.core import TensorTKD
>>> I, J, K = 5, 6, 7 # shape of the tensor in full form
>>> R_1, R_2, R_3 = 2, 3, 4 # multi-linear rank
>>> A = np.ones((I, R_1))
>>> B = np.ones((J, R_2))
>>> C = np.ones((K, R_3))
>>> fmat = [A, B , C]
>>> core_values=np.ones((R_1, R_2, R_3))
>>> mode_names=["Year", "Month", "Day"]
>>> tensor_tkd = TensorTKD(fmat, core_values, mode_names)
>>> print(tensor_tkd)
Tucker representation of a tensor with multi-linear rank=(2, 3, 4).
Factor matrices represent properties: ['Year', 'Month', 'Day']
With corresponding latent components described by (5, 6, 7) features respectively.
Methods
|
Produces a copy of itself as a new object |
|
Copy modes meta from tensor |
|
Converts the Tucker 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
¶Core tensor of the Tucker representation of a tensor
fmat
¶List of factor matrices for the Tucker representation of a tensor
ft_shape
¶Shape of a TensorTKD
in the full format
mode_names
¶Description of the physical modes for a TensorTKD
modes
¶Meta data for the factor matrices
order
¶Order of a tensor represented through the TKD
rank
¶Multi-linear rank of the Tucker representation of a tensor
Notes
Most often referred to as the Tucker rank
reconstruct
(self, keep_meta=0)[source]¶Converts the Tucker 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