(This is my first time of asking a question, if you think the tags or description have something wrong, please tell me, thank you!)
I'm doing a work on Matrix Factorization
and use the module sklearn.decomposition.nmf
the module uses another module
from sklearn.decomposition.cdnmf_fast import _update_cdnmf_fast
This module is from file cdnmf_fast.so
You can check out its source code on this website
/sklearn/decomposition/cdnmf_fast.pyx
We can see that it uses C-language and "with nogil:", so I think it must have used parallelization.
So I write a similar code to test it as follows:
from sklearn.decomposition.cdnmf_fast import _update_cdnmf_fast
import numpy as np
from numpy import *
M = 3
X = zeros((M,M), dtype="float64")
U = ones((M,M), dtype="float64")
V = np.arange(M*M).reshape(M,M).astype("float64")
permutation = np.arange(M)
print X
print U
print V
print permutation
x = _update_cdnmf_fast(X,U,V,permutation)
print X
The expected result is X=X+V-W*U=0+V-0=V. However, the result is strange and it's far more slowly than np.dot(). Then I change this code into normal python code, not parallelization code. The result is the same as before. So I'm sure that its parallelization is not working. Because it's using X while it's changing X, the result is of course wrong. I don't know why its parallelization is not working. Is it due to the bug of the module or the method of the way I import?
Actually, this makes me concerned when I use the sklearn.decomposition.nmf module, I'm not sure when I use this module, whether its parallelization is also not working or not. So I want to know how it makes the parallelization work.
Thank you for your help!