cNMF
cNMF copied to clipboard
cnmf consensus TypeError: H should have the same dtype as X. Got H.dtype = float64.
Hi, I encountered the "TypeError: H should have the same dtype as X. Got H.dtype = float64." when running the last step (cnmf consensus
). I have tried all suggestions in https://github.com/dylkot/cNMF/issues/9 and https://github.com/dylkot/cNMF/issues/8#issue-651940726, but all failed. Could anyone please let me know how to solve the problem? Where exactly I should add norm_counts.X = norm_counts.X.astype(np.float64)
in cnmf.py?
BTW, I used the most recent version of cnmf.py
in the master branch.
The solution #10 helped with the problem. I had the exact same error as yours before and I found that there's actually no need to add norm_counts.X = norm_counts.X.astype(np.float64)
.
Hi, I encountered the "TypeError: H should have the same dtype as X. Got H.dtype = float64." when running the last step (
cnmf consensus
). I have tried all suggestions in #9 and #8 (comment), but all failed. Could anyone please let me know how to solve the problem? Where exactly I should addnorm_counts.X = norm_counts.X.astype(np.float64)
in cnmf.py?BTW, I used the most recent version of
cnmf.py
in the master branch.
Thanks! According to the #10 post, my understanding is that H = H.astype(np.float64)
should be added within the "def _check_w_h" function (as suggested by njh219). However, I am not sure which script to locate. I can only find the cnmf.py
. Could you please point me to the NMF Scikit-learn code? I really appreciated your help!
The solution #10 helped with the problem. I had the exact same error as yours before and I found that there's actually no need to add
norm_counts.X = norm_counts.X.astype(np.float64)
.Hi, I encountered the "TypeError: H should have the same dtype as X. Got H.dtype = float64." when running the last step (
cnmf consensus
). I have tried all suggestions in #9 and #8 (comment), but all failed. Could anyone please let me know how to solve the problem? Where exactly I should addnorm_counts.X = norm_counts.X.astype(np.float64)
in cnmf.py? BTW, I used the most recent version ofcnmf.py
in the master branch.
You can search in your conda env: cnmf_env/lib/python3.7/site-packages/sklearn/decomposition/_nfm.py
I, too, encountered this error when running the consensus step.
I am a little concerned about tweaking the sklearn _cnmf.py and cnmf.py scripts as they are installed packages.
Is it possible for the authors to add in this bug fix?
Hi @humengying0907. I followed your instructions and still getting the same error.
Is it right to modify _nfm.py in my conda environment like this?
elif not update_H:
_check_init(H, (self._n_components, n_features), "NMF (input H)")
H = H.astype(np.float64)
if H.dtype != X.dtype:
raise TypeError(
"H should have the same dtype as X. Got H.dtype = {}.".format(
H.dtype
)
)
Thanks!
It might help to update anndata to version >0.9 in your python environment (see #71)
This should be addressed now as per issue #71. Sorry for being slow to get to this. Let me know if there are ongoing issues.