Module 'dgl' has no attribute 'radius_graph'

Hello, my code contains dgl graph construction as follows:

def construct_graph(self,
                    position: Tensor,
                    self_edge: bool = True):
    """
    :param position: particle positions [#. particles, dim]
    :param self_edge:
    :return: dgl graph
    """

    return dgl.radius_graph(position, self.connectivity_radius, self_edge)

When running the code, the error is as follows:

~~~~


D:\PyCharms\PytorchGNS\gns\gns.py in <listcomp>(.0)
    140         # construct graph
    141         batched_g = dgl.batch([self.construct_graph(p[:, -1, :],
--> 142                                                     self_edge) for p in positions.split(list(num_particles))])
    143         batched_g = batched_g.to(device)
    144 

D:\PyCharms\PytorchGNS\gns\gns.py in construct_graph(self, position, self_edge)
    198         """
    199 
--> 200         return dgl.radius_graph(position, self.connectivity_radius, self_edge)
    201 
    202     def _compute_ef(self, edges):

AttributeError: module 'dgl' has no attribute 'radius_graph'





I check the installation info and checked that dgl version 0.9.0 is properly installed.  I don't know why it does not recognize 'radius_graph' attribute.   Can anyone help??

I tried with the latest 0.9 version and can successfully import radius_graph

>>> import dgl
>>> dgl.radius_graph
<function radius_graph at 0x7f23c1b119e0>

Could you verify the version and the installed path of the dgl package by printing dgl.__version__ and dgl.__path__? We found sometimes there could be multiple DGL installed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.