0

I changed all matrices in my formula to scipy.sparse.csr_matrix()

H = sp.csr_matrix(H)
V = sp.csr_matrix(V)
W = sp.csr_matrix(W)

And want to update this equation

H = H * np.dot(Wt,(V/(np.dot(W,H)))) / np.dot(Wt,ONES)

Where Wt is W.conj().T and ONES is np.ones(shape=(row,col))

I already change all dot product and elementwise multiplication but get stuck at the division

H = H.multiply(Wt.dot(V/(W.dot(H)))) / Wt.dot(ONES)

How to change / here in this equation for scipy sparse matrix operation?

Jan
  • 1,389
  • 4
  • 17
  • 43
  • 1
    Is that element by element division? Since most elements of a sparse matrix are 0 that will produce a zero-division error(s). https://stackoverflow.com/q/44080315 – hpaulj Jun 07 '17 at 11:51
  • @hpaulj Yes, it is elementwise division. I may misundestand this but if the numpy matrix is already changed to scipy sparse matrix, it will not have memory for zero element? So that the element which is zero will not be computed in this case? – Jan Jun 07 '17 at 11:59
  • 1
    The sparse matrix just stores the nonzero values, but the matrix still has the full shape. The zero values are there - implied. Otherwise calculations like matrix and elementwise multiplication wouldn't be consistent between sparse and dense matrices. This isn't masking. – hpaulj Jun 07 '17 at 15:53

0 Answers0