tensorly.cp_tensor
.cp_to_unfolded

cp_to_unfolded
(cp_tensor, mode)[source] Turns the khatriproduct of matrices into an unfolded tensor
turnsfactors = [U_1, ... U_n]
into a modemode unfolding of the tensorParameters:  cp_tensorCPTensor = (weight, factors)
factors is a list of matrices, all with the same number of columns ie for all u in factor_matrices: u[i] has shape (s_u_i, R), where R is fixed
 mode: int
mode of the desired unfolding
Returns:  ndarray
unfolded tensor of shape (tensor_shape[mode], 1)
Notes
Writing factors = [U_1, …, U_n], we exploit the fact that
U_k = U[k].dot(khatri_rao(U_1, ..., U_k1, U_k+1, ..., U_n))