stnmf.nnls.afhals

stnmf.nnls.afhals(vht, hht, w0, rho=0.0, alpha=0.5, eps=0.1, lmbda=0, inplace=False)

Accelerated fast hierarchical alternating least squares (AF-HALS) update

AF-HALS is based on fast hierarchical alternating least squares (Fast HALS) [1] combined with accelerated hierarchical alternating least squares (A-HALS) [2], as inner update for W in:

\(\mathbf{V} \approx \mathbf{W}\mathbf{H}^\top\)

Parameters:
  • vht ((n,r) array_like) – Product of v and h.T, where v is an (n, m) array_like and h is an (r, m) array_like

  • hht ((r,r) array_like) – Product of h and h.T, where h is (r, m)

  • w0 ((m,r) array_like) – Initialized matrix w

  • rho (float, optional) – Rho for w as computed in [2]. If zero, no inner update loops will be done, which reverts back to fast HALS. Default is 0.0

  • alpha (float, optional) – This is the scaling parameter for rho as described in [2]. Default is 0.5

  • eps (float, optional) – Epsilon is the scaling parameter for the relative error as described in [2]. Default is 0.1

  • lmbda (float, optional) – Weight of sparsity constraint. Default is 0

  • inplace (bool, optional) – If True, compute w in-place by modifying w0. This only succeeds if w is of type numpy.ndarray. Default is False

Returns:

w ((m,r) numpy.ndarray) – Updated matrix w

Notes

Since the update is symmetric, if updating h instead, the first three parameters change to the following. Additionally, a suitable rho should be supplied for h instead.

Other Parameters:
  • vtw ((m,r) array_like) – Product of v.T and w, where v is an (n, m) array_like and w is an (n, r) array_like

  • wtw ((r,r) array_like) – Product of w.T and w, where w is an (n, r) array_like

  • ht0 ((m,r) array_like) – Initialized matrix h.T, where h is an (r, m) array_like

Notes

All of the matrix operations are performed in-place to reduce memory cost and computational time on repeated allocations. The update of w is performed with

\[\mathbf{W}_j\leftarrow\left [\mathbf{W}_j+ (\mathbf{V}\mathbf{H}^\top)_j-\mathbf{W} (\mathbf{H}\mathbf{H}^\top)_j-\lambda\right]_+\,,\]

where \(\mathbf{A}_j\) is the \(j\) th column of \(\mathbf{A}\) and \([\mathbf{A}]_+\) is the element wise \(\max(\mathbf{A}, 0)\).

The expensive matrix calculations \(\mathbf{V}\mathbf{H}^\top\) and \(\mathbf{H}\mathbf{H}^\top\) are done separately from the outer update loop as suggested by [2]. Additionally, \(\mathbf{W}+(\mathbf{V}\mathbf{H}^\top)\) is calculated only once for each inner update loop.

References