pyttb
pyttb copied to clipboard
Optimize a subset of factor matrices in cp_als?
I propose allowing cp_als()
to optimize a subset of the factor matrices.
As motivation consider the case of streaming CP for T in R^(m x n x p)
where we receive slices X in R^(m x n)
a few at a time; further suppose that the factor matrices for mode 1 and 2 are fixed (assuming something like "the concepts do not drift in time"). Such a simplified setting is also discussed here in the beginning of section 3.1.
Given a few slices, we must compute the corresponding rows of of the "temporal" factor matrix; this is equivalent to solving the temporal linear least squares subproblem where our data tensor is m x n x <few>
.
Since the current implementation of cp_als()
completes a full sweep (here 3 least squares subproblems) before checking for convergence it's not possible (or at best not simple) to coax cp_als()
into performing such a computation.
With the proposed changes this streaming solve would be as easy as
cp_als(X, r, init=<ktensor with [A,B,???]>, optdims=[2],maxiters=1) # ??? doesn't matter
where we choose maxiters=1
because it's simply a linear least squares problem so no iteration is needed.
An implementation is given in #302.