tensorly.cp_tensor.cp_to_unfolded

cp_to_unfolded(cp_tensor, mode)[source]

Turns the khatri-product of matrices into an unfolded tensor

turns factors = [|U_1, ... U_n|] into a mode-mode unfolding of the tensor

Parameters:
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_k-1, U_k+1, ..., U_n))