Module props: various simple properties of TT-tensors¶
Package teneva, module props: various properties of TT-tensors.
This module contains the basic properties of TT-tensors, including “erank”, “ranks”, “shape”, etc.
- teneva.props.erank(Y)[source]¶
Compute effective TT-rank of the given TT-tensor.
Effective TT-rank r of a TT-tensor Y with shape [n_1, n_2, …, n_d] and TT-ranks r_0, r_1, …, r_d (r_0 = r_d = 1) is a solution of equation n_1 r + sum_{lpha=2}^{d-1} n_lpha r^2 + n_d r = sum_{lpha=1}^{d} n_lpha r_{lpha-1} r_{lpha}.
The representation with a constant TT-rank r (r_0 = 1, r_1 = r_2 = … = r_{d-1} = r, r_d = 1) yields the same total number of parameters as in the original decomposition of the tensor Y.
- Parameters:
Y (list) – TT-tensor.
- Returns:
effective TT-rank.
- Return type:
float
Examples:
# 10-dim random TT-tensor with TT-rank 2: Y = teneva.rand([5]*10, 2) # The effective TT-rank: teneva.erank(Y) # >>> ---------------------------------------- # >>> Output: # 2.0 #
Note that it also works for 2-dimensional arrays (i.e., matrices):
# 2-dim random TT-tensor (matrix) with TT-rank 20: Y = teneva.rand([5]*2, 20) # The effective TT-rank: teneva.erank(Y) # >>> ---------------------------------------- # >>> Output: # 20 #
- teneva.props.ranks(Y)[source]¶
Return the TT-ranks of the given TT-tensor.
- Parameters:
Y (list) – TT-tensor.
- Returns:
TT-ranks in form of the 1D array of ints of the length d+1, where d is a number of tensor dimensions (the first and last elements are equal 1).
- Return type:
np.ndarray
Examples:
# 5-dim random TT-tensor with TT-rank 2: Y = teneva.rand([10, 12, 8, 8, 30], 2) # TT-ranks of the TT-tensor: teneva.ranks(Y) # >>> ---------------------------------------- # >>> Output: # array([1, 2, 2, 2, 2, 1]) #
- teneva.props.shape(Y)[source]¶
Return the shape of the given TT-tensor.
- Parameters:
Y (list) – TT-tensor.
- Returns:
shape of the tensor in form of the 1D array of ints of the length d, where d is a number of tensor dimensions.
- Return type:
np.ndarray
Examples:
# 5-dim random TT-tensor with TT-rank 2: Y = teneva.rand([10, 12, 8, 8, 30], 2) # Shape of the TT-tensor: teneva.shape(Y) # >>> ---------------------------------------- # >>> Output: # array([10, 12, 8, 8, 30]) #
- teneva.props.size(Y)[source]¶
Return the size (number of parameters) of the given TT-tensor.
- Parameters:
Y (list) – TT-tensor.
- Returns:
total number of parameters in the TT-representation (it is a sum of sizes of all TT-cores).
- Return type:
int
Examples:
# 5-dim random TT-tensor with TT-rank 2: Y = teneva.rand([10, 12, 8, 8, 30], 2) # Size of the TT-tensor: teneva.size(Y) # >>> ---------------------------------------- # >>> Output: # 192 #