tensorly.tenalg
.unfolding_dot_khatri_rao
- unfolding_dot_khatri_rao(tensor, cp_tensor, mode)[source]
mode-n unfolding times khatri-rao product of factors
- Parameters:
- tensortl.tensor
tensor to unfold
- factorstl.tensor list
list of matrices of which to the khatri-rao product
- modeint
mode on which to unfold tensor
- Returns:
- mttkrp
dot(unfold(tensor, mode), khatri-rao(factors))
Notes
Default unfolding_dot_khatri_rao implementation.
Implemented as the product between an unfolded tensor and a Khatri-Rao product explicitly formed. Due to matrix-matrix products being extremely efficient operations, this is a simple yet hard-to-beat implementation of MTTKRP.
If working with sparse tensors, or when the CP-rank of the CP-tensor is comparable to, or larger than, the dimensions of the input tensor, however, this method requires a lot of memory, which can be harmful when dealing with large tensors. In this case, please use the memory-efficient version of MTTKRP.
To use the slower memory efficient version, run
>>> from tensorly.tenalg.core_tenalg.mttkrp import unfolding_dot_khatri_rao_memory >>> tl.tenalg.register_backend_method("unfolding_dot_khatri_rao", unfolding_dot_khatri_rao_memory) >>> tl.tenalg.use_dynamic_dispatch()