gao-lab / Cell_BLAST

A BLAST-like toolkit for large-scale scRNA-seq data querying and annotation.
http://cblast.gao-lab.org
MIT License
82 stars 13 forks source link

Tensorflow version 2.0.0 question #6

Closed caiquanyou closed 4 years ago

caiquanyou commented 4 years ago

i run import Cell_BLAST as cb and these feedback: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/dist-packages/Cell_BLAST/__init__.py", line 11, in <module> from . import (blast, config, data, directi, latent, metrics, prob, rmbatch, File "/usr/local/lib/python3.6/dist-packages/Cell_BLAST/blast.py", line 19, in <module> from . import config, data, directi, metrics, utils File "/usr/local/lib/python3.6/dist-packages/Cell_BLAST/directi.py", line 16, in <module> from . import config, data, latent, model, prob, rmbatch, utils File "/usr/local/lib/python3.6/dist-packages/Cell_BLAST/latent.py", line 13, in <module> from . import module, nn, utils File "/usr/local/lib/python3.6/dist-packages/Cell_BLAST/module.py", line 15, in <module> class Module(object): File "/usr/local/lib/python3.6/dist-packages/Cell_BLAST/module.py", line 32, in Module def _save_weights(self, sess: tf.Session, path: str) -> None: AttributeError: module 'tensorflow' has no attribute 'Session' How to fix these problems?

Jeff1995 commented 4 years ago

Thanks for your interest in Cell BLAST. Unfortunately, we do not support tensorflow v2. For now, my recommendation is to stick with tensorflow v1.x (e.g., you can install v1 in a separate conda environment if that would cause conflict with other packages).

We currently do not plan to rewrite the entire project in tensorflow v2, but we can probably maintain compatibility across both v1 and v2 by replacing all import tensorflow as tf with:

import packaging.version
import tensorflow as tf
if packaging.version.parse(tf.__version__) >= packaging.version.parse("2.0.0"):
    import tensorflow.compat.v1 as tf
    tf.disable_v2_behavior()

I'm not entirely sure whether that would work seemlessly, since I personally haven't tried v2 yet. Let us know if you have experience migrating between tensorflow v1 and v2. Contribution is welcomed.