quick_tensorcpd

# 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

Parameters
full_shapetuple

Desired shape of the tensor when it is reconstructed. Values specify the number of rows of the factor matrices.

ranktuple

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,)

basestr

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.

Returns
tensor_cpdTensorCPD

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.