StatBiomed / UniTVelo

UniTVelo, Temporally Unified RNA Velocity for single cell trajectory inference
https://unitvelo.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
25 stars 9 forks source link

TypeError: Tensor is unhashable. #30

Closed Linxiaobuskiy closed 1 year ago

Linxiaobuskiy commented 1 year ago

Hi, I'm trying to run the example as https://unitvelo.readthedocs.io/en/latest/Figure2_ErythroidMouse.html shows. When I run:

adata = utv.run_model('./data/Gastrulation/erythroid_lineage.h5ad', label, config_file=velo_config)

I received the error:

Traceback (most recent call last): File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/pandas/core/arrays/categorical.py", line 431, in init codes, categories = factorize(values, sort=True) File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/pandas/core/algorithms.py", line 760, in factorize codes, uniques = factorize_array( File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/pandas/core/algorithms.py", line 562, in factorize_array uniques, codes = table.factorize( File "pandas/_libs/hashtable_class_helper.pxi", line 5396, in pandas._libs.hashtable.PyObjectHashTable.factorize File "pandas/_libs/hashtable_class_helper.pxi", line 5310, in pandas._libs.hashtable.PyObjectHashTable._unique File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/tensorflow/python/framework/ops.py", line 897, in hash raise TypeError("Tensor is unhashable. " TypeError: Tensor is unhashable. Instead, use tensor.ref() as the key.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/unitvelo/main.py", line 64, in run_model adata = model.fit_velo_genes(basis=basis, rep=rep) File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/unitvelo/velocity.py", line 284, in fit_velo_genes scv.tl.latent_time(adata, min_likelihood=None) File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/scvelo/tools/dynamical_model.py", line 804, in latent_time terminal_states(adata, vkey=vkey) File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/scvelo/tools/terminal_states.py", line 275, in terminal_states strings_to_categoricals(adata) File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/scvelo/tools/utils.py", line 304, in strings_to_categoricals c = Categorical(c) File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/pandas/core/arrays/categorical.py", line 433, in init codes, categories = factorize(values, sort=False) File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/pandas/core/algorithms.py", line 760, in factorize codes, uniques = factorize_array( File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/pandas/core/algorithms.py", line 562, in factorize_array uniques, codes = table.factorize( File "pandas/_libs/hashtable_class_helper.pxi", line 5396, in pandas._libs.hashtable.PyObjectHashTable.factorize File "pandas/_libs/hashtable_class_helper.pxi", line 5310, in pandas._libs.hashtable.PyObjectHashTable._unique File "/home/linqianyu/anaconda3/envs/UniTVelo/lib/python3.9/site-packages/tensorflow/python/framework/ops.py", line 897, in hash raise TypeError("Tensor is unhashable. " TypeError: Tensor is unhashable. Instead, use tensor.ref() as the key.

All the parameters are same with the example, same error also occur when I tried to run my own data.

Linxiaobuskiy commented 1 year ago

error fixed by going back to python 3.7

michaelgmz commented 1 year ago

Hi for spotting this issue, I'll keep an eye on version conflicts. Many thanks.

molecules commented 9 months ago

Might something from the following allow you to use later versions of Python?

https://stackoverflow.com/questions/61056781/typeerror-tensor-is-unhashable-instead-use-tensor-ref-as-the-key-in-keras