-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "TypeError: expected Tensor as element 0 in argument 0, but got numpy.ndarray" when running "st.alignment.morpho_align" #277
Comments
I reinstalled the spateo-release with "yifan branch". |
Hi, could you provide more information? For example, the function you're running, so I can better understand what's going wrong and help troubleshoot. |
align_8W9W, pis_8W9W = st.alignment.morpho_align( |
Hi, thanks for providing the information. However, the issue seems a bit strange to me since the error appears to be related to sparse calculations. But from the code you've shared, it looks like the sparse_calculation_mode has been commented out. I have two suggestions:
I hope this helps! |
when I run the code, I did not commented out the "sparse_calculation_mode=True", and I got the error. Then I reinstalled the spateo and rerun the code. and got the result when I comment out the "sparse_calculation_mode=True" |
Hi, thank you for your feedback! Just to confirm, did this solution work for you? |
My data is about 20k~60k cells. if I comment out "sparse_calculation_mode=True". The task would be memory out. |
Hi @forrwill, I apologize for this mistake and thank you for raising the issue. I believe I've found the bug. I noticed that your output includes: GPU is not available, resorting to torch cpu. This means the code is not utilizing the GPU for PyTorch calculations. When We will need some time to fix this bug since it involves implementing sparse calculations using SciPy’s sparse operations for CPU mode. In the meantime, I suggest checking your PyTorch GPU installation. You can verify if the GPU is set up correctly by running:
Once PyTorch GPU is installed correctly, you should be able to use Spateo alignment without any issues. In summary, the current issue seems to be with CPU + sparse calculation in Spateo alignment. I hope this helps, and please let me know if you have any other questions. |
In fact, I have tested it in GPU mode, But It was stoped without any error reported, So I am not sure whether it is a bug. Anyway, thank you very much. Please let me know the time point of the update version, Thank you very much! |
Hi @forrwill, thank you again for raising this issue. I have fixed the bugs related to CPU + sparse calculation in Spateo alignment. I tested the following configuration, and the results look good: |
Hi @forrwill , I have updated the code in the latest main branch |
Hi, I met the error "TypeError: expected Tensor as element 0 in argument 0, but got numpy.ndarray",
I had run the function successfully before. But now, It was failed with the error, could you please help me figure out the question.
^M|-----> [Models alignment based on morpho, mode: SN-S.] in progress: 100.0000%|-----> GPU is not available, resorting to torch cpu.
|-----> Filtered all samples for common genes. There are 30356 common genes.
|-----> Spatial coordinates normalization params:
|-----------> Scale: [1357.2966 1357.2966]...
|-----------> Scale: [[18417.703 23149.129 241.7397 ]
[19898.088 8253.436 331.55087]]...
|-----> Preprocess finished.
|-----> Performing coarse rigid alignment...
|-----> Coarse rigid alignment done.
Traceback (most recent call last):
File "./Spateo.test.py", line 60, in
align_8W9W, pis_8W9W = st.alignment.morpho_align(
File "
/Miniconda3/envs/spateo_env/lib/python3.9/site-packages/spateo_release-1.1.0-py3>/Miniconda3/envs/spateo_env/lib/python3.9/site-packages/torch/utils/_contextlib.>P = morpho_model.run()
File "
return func(*args, **kwargs)
File "
/Miniconda3/envs/spateo_env/lib/python3.9/site-packages/spateo_release-1.1.0-py3>/Miniconda3/envs/spateo_env/lib/python3.9/site-packages/spateo_release-1.1.0-py3>self._update_assignment_P()
File "
self.P, self.K_NA_spatial, self.K_NA_sigma2, sigma2_related = get_P_core(
File "
/Miniconda3/envs/spateo_env/lib/python3.9/site-packages/spateo_release-1.1.0-py3>/Miniconda3/envs/spateo_env/lib/python3.9/site-packages/spateo_release-1.1.0-py3>P = _dense_to_sparse(
File "
results = _SparseTensor(nx=nx, row=row, col=col, value=val, sparse_sizes=(NA, NB))
File "~/Miniconda3/envs/spateo_env/lib/python3.9/site-packages/spateo_release-1.1.0-py3>
return SparseTensor(indices=torch.vstack((row, col)), values=value, size=sparse_sizes)
TypeError: expected Tensor as element 0 in argument 0, but got numpy.ndarray
It was confusing that I run the "st.alignment.morpho_align_ref" successfully.
The text was updated successfully, but these errors were encountered: