Irrationone / cellassign

Automated, probabilistic assignment of cell types in scRNA-seq data
Other
191 stars 79 forks source link

AttributeError: module 'tensorflow' has no attribute 'reset_default_graph' #49

Closed VicenteFR closed 4 years ago

VicenteFR commented 4 years ago

Hi, everyone!

I was trying to process the data sets from SingleCellExperiment package as shown in the tutorial but, when trying to run:

fit <- cellassign(exprs_obj = example_sce, marker_gene_info = example_rho, s = s, learning_rate = 1e-2, shrinkage = TRUE, verbose = FALSE)

I've faced this error from tensorflow:

Error in py_get_attr_impl(x, name, silent) : AttributeError: module 'tensorflow' has no attribute 'reset_default_graph

Apparently, it has something to do with the way the module tensorflow could be imported in a python session as commented in this thread. Any suggestions to solve this?

Thanks so much!

kieranrcampbell commented 4 years ago

I think the issue is you probably have tensorflow 2.0 installed. Can you check this with

tensorflow::tf_config()

cellassign was written in tensorflow 1.X and we've been dreading the day the 2.0 candidate was released. The moral of the story is don't develop in tensorflow.

If the above does indeed show you have 2.X installed, you can downgrade via

install_tensorflow(your_options, version='1.14')

kieranrcampbell commented 4 years ago

@Irrationone looks like there might be a quick fix via the use_compat function https://www.rdocumentation.org/packages/tensorflow/versions/1.14.0/topics/use_compat

VicenteFR commented 4 years ago

Got ya'!

Problem solved! Now there are a lot of warnings output, but all of them related to the new tensorflow version.

Thanks, thanks!

honghh2018 commented 3 years ago

Hi, i get the same issue. whatever the ways i use that you post above, it can not be solved. I use the conda to install the cellassign, and then i enter the R to type the tensorflow::tf_config(), it alway showing the tensorflow's path '~/miniconda3/envs/reticulate_venv/lib/python3.8/site-packages/'. But the conda environment that i install the cellassign was in "/test/Data/software/mini_conda/Miniconda3/envs/Cellassign" . It was very weird. how can i change the tensorflow path in the conda environment that i use. Any advice would be grateful. Best, hanhuihong

honghh2018 commented 3 years ago

The conda environment's tensorflow'R package: image

But the tensorflow: tensorflow::tf_config() TensorFlow v2.5.0 (/home/test/miniconda3/envs/reticulate_venv/lib/python3.8/site-packages/tensorflow) Python v3.8 (/home/test/miniconda3/envs/reticulate_venv/bin/python)

honghh2018 commented 3 years ago

@Irrationone looks like there might be a quick fix via the use_compat function https://www.rdocumentation.org/packages/tensorflow/versions/1.14.0/topics/use_compat It can not be work on my case. it still load into tensorflow 2.5