awslabs / dgl-lifesci

Python package for graph neural networks in chemistry and biology
Apache License 2.0
714 stars 147 forks source link

TF backend support #126

Closed popfido closed 3 years ago

popfido commented 3 years ago

I'm using tensorflow as dgl backend in my local macbook since apple release its Metal-accelerated version of tensorflow. But it seems that the dgl-lifesci does not support tensorflow backend when I import dgllife.

In [1]: import dgllife
Using backend: tensorflow
2021-01-05 11:13:59.073796: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-68d2941e7384> in <module>
----> 1 import dgllife

~/anaconda3/envs/main/lib/python3.8/site-packages/dgllife/__init__.py in <module>
      7
      8 from .libinfo import __version__
----> 9 from . import model
     10
     11 try:

~/anaconda3/envs/main/lib/python3.8/site-packages/dgllife/model/__init__.py in <module>
      4 # SPDX-License-Identifier: Apache-2.0
      5
----> 6 from .gnn import *
      7 from .readout import *
      8 from .model_zoo import *

~/anaconda3/envs/main/lib/python3.8/site-packages/dgllife/model/gnn/__init__.py in <module>
      6 # Graph neural networks for updating node representations
      7
----> 8 from .attentivefp import *
      9 from .gat import *
     10 from .gcn import *

~/anaconda3/envs/main/lib/python3.8/site-packages/dgllife/model/gnn/attentivefp.py in <module>
     12 import torch.nn.functional as F
     13
---> 14 from dgl.nn.pytorch import edge_softmax
     15
     16 __all__ = ['AttentiveFPGNN']

ModuleNotFoundError: No module named 'dgl.nn.pytorch'

So dgllife currently only support pytorch as backend engine and did not intend to be prepared in 0.3 roadmap?

mufeili commented 3 years ago

Yes. Due to limited bandwidth, we do not plan to support TF.

danielmanu93 commented 3 years ago

I am having a similar problem. I'm using pytorch backend to import dgllife but I get this error "ModuleNotFoundError: No module named 'dgl.nn.functional'". How can I fix this.

1

mufeili commented 3 years ago

I am having a similar problem. I'm using pytorch backend to import dgllife but I get this error "ModuleNotFoundError: No module named 'dgl.nn.functional'". How can I fix this.

1

You need to update DGL to 0.6.x.

danielmanu93 commented 3 years ago

After I updated DGL to 0.6.1 using conda, the error has changed to "ImportError: cannot import name 'smiles_to_graph' from 'dgllife.utils' " as shown below. 1

Below is the code I'm tryna execute: 1

mufeili commented 3 years ago

After I updated DGL to 0.6.1 using conda, the error has changed to "ImportError: cannot import name 'smiles_to_graph' from 'dgllife.utils' " as shown below. 1

Below is the code I'm tryna execute: 1

You need to change smiles_to_graph to smiles_to_bigraph.

danielmanu93 commented 3 years ago

Thank you! It worked

danielmanu93 commented 3 years ago

How do I access only the number of edges in the graph? I used g[1] but I get an error. Below is how it appear when I print the graph (g). The second attribute is the number of edges.

1

mufeili commented 3 years ago

How do I access only the number of edges in the graph? I used g[1] but I get an error. Below is how it appear when I print the graph (g). The second attribute is the number of edges.

1

You can use g.num_edges(). See also the API reference for DGL.

mufeili commented 3 years ago

Hi I'm having this issue with SMILES parse error. I'm trying to generate molecules from smiles with the attached generate function but I get the "SMILES parse error" in the terminal when I call the function. How can I fix this issue?

1 2

These appear to be issues related to RDKit so you should open an issue there. If you have further issues, please open a new thread as they are irrelevant to this thread.