cp_to_tensor(cp_tensor, mask=None)[source]

Turns the Khatri-product of matrices into a full tensor

factor_matrices = [|U_1, ... U_n|] becomes a tensor shape (U[1].shape[0], U[2].shape[0], ... U[-1].shape[0])
cp_tensorCPTensor = (weight, factors)

factors is a list of factor matrices, all with the same number of columns i.e. for all matrix U in factor_matrices: U has shape (s_i, R), where R is fixed and s_i varies with i

maskndarray a mask to be applied to the final tensor. It should be

broadcastable to the shape of the final tensor, that is (U[1].shape[0], ... U[-1].shape[0]).


full tensor of shape (U[1].shape[0], ... U[-1].shape[0])


This version works by first computing the mode-0 unfolding of the tensor and then refolding it.

There are other possible and equivalent alternate implementation, e.g. summing over r and updating an outer product of vectors.