# Import statement
from hottbox.utils.generation import quick_tensorcpd
quick_tensorcpd
(full_shape, rank, base='arange')[source]¶Simplified creation of generic tensor in kruskal form
Desired shape of the tensor when it is reconstructed. Values specify the number of rows of the factor matrices.
Desired kruskal rank of the tensor. Specifies the number of columns for all factor matrices.
In order to be consistent with the rest of hottbox
should be in form of (value,)
Id of base function that generates values for the components of kruskal tensor.
If not one from {"arange", "randn", "rand", "ones"}
then np.arange
will be used.
Examples
>>> from hottbox.utils.generation import quick_tensorcpd
>>> tensor_cpd = quick_tensorcpd(full_shape=(3, 4, 5), rank=(2,), base="ones")
>>> print(tensor_cpd)
Kruskal representation of a tensor with rank=(2,).
Factor matrices represent properties: ['mode-0', 'mode-1', 'mode-2']
With corresponding latent components described by (3, 4, 5) features respectively.
>>> tensor = tensor_cpd.reconstruct()
>>> print(tensor)
This tensor is of order 3 and consists of 60 elements.
Sizes and names of its modes are (3, 4, 5) and ['mode-0', 'mode-1', 'mode-2'] respectively.