Commit 82499e60 authored by xiang song(charlie.song)'s avatar xiang song(charlie.song) Committed by Minjie Wang
Browse files

[Bug Fix] Fix package reliability bug of networkx (#949)

* upd

* fig edgebatch edges

* add test

* trigger

* Update README.md for pytorch PinSage example.

Add noting that the PinSage model example under
example/pytorch/recommendation only work with Python 3.6+
as its dataset loader depends on stanfordnlp package
which work only with Python 3.6+.

* Provid a frame agnostic API to test nn modules on both CPU and CUDA side.

1. make dgl.nn.xxx frame agnostic
2. make test.backend include dgl.nn modules
3. modify test_edge_softmax of test/mxnet/test_nn.py and
    test/pytorch/test_nn.py work on both CPU and GPU

* Fix style

* Delete unused code

* Make agnostic test only related to tests/backend

1. clear all agnostic related code in dgl.nn
2. make test_graph_conv agnostic to cpu/gpu

* Fix code style

* fix

* doc

* Make all test code under tests.mxnet/pytorch.test_nn.py
work on both CPU and GPU.

* Fix syntex

* Remove rand

* Add TAGCN nn.module and example

* Now tagcn can run on CPU.

* Add unitest for TGConv

* Fix style

* For pubmed dataset, using --lr=0.005 can achieve better acc

* Fix style

* Fix some descriptions

* trigger

* Fix doc

* Add nn.TGConv and example

* Fix bug

* Update data in mxnet.tagcn test acc.

* Fix some comments and code

* delete useless code

* Fix namming

* Fix bug

* Fix bug

* Add test for mxnet TAGCov

* Add test code for mxnet TAGCov

* Update some docs

* Fix some code

* Update docs dgl.nn.mxnet

* Update weight init

* Fix

* reproduce the bug

* Fix concurrency bug reported at #755.
Also make test_shared_mem_store.py more deterministic.

* Update test_shared_mem_store.py

* Update dmlc/core

* networkx >= 2.4 will break our examples

* Update tutorials/requirements

* fix selfloop edges

* upd version
parent 98c1448b
...@@ -11,6 +11,7 @@ Pytorch implementation: https://github.com/Diego999/pyGAT ...@@ -11,6 +11,7 @@ Pytorch implementation: https://github.com/Diego999/pyGAT
""" """
import argparse import argparse
import networkx as nx
import time import time
import mxnet as mx import mxnet as mx
from mxnet import gluon from mxnet import gluon
...@@ -58,7 +59,7 @@ def main(args): ...@@ -58,7 +59,7 @@ def main(args):
# create graph # create graph
g = data.graph g = data.graph
# add self-loop # add self-loop
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g = DGLGraph(g) g = DGLGraph(g)
g.add_edges(g.nodes(), g.nodes()) g.add_edges(g.nodes(), g.nodes())
# create model # create model
......
"""Training GCN model on citation graphs.""" """Training GCN model on citation graphs."""
import argparse, time import argparse, time
import numpy as np import numpy as np
import networkx as nx
import mxnet as mx import mxnet as mx
from mxnet import gluon from mxnet import gluon
...@@ -54,7 +55,7 @@ def main(args): ...@@ -54,7 +55,7 @@ def main(args):
# create GCN model # create GCN model
g = data.graph g = data.graph
if args.self_loop: if args.self_loop:
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g.add_edges_from(zip(g.nodes(), g.nodes())) g.add_edges_from(zip(g.nodes(), g.nodes()))
g = DGLGraph(g) g = DGLGraph(g)
# normalization # normalization
......
import argparse, time import argparse, time
import numpy as np import numpy as np
import networkx as nx
import mxnet as mx import mxnet as mx
from mxnet import gluon from mxnet import gluon
...@@ -52,7 +53,7 @@ def main(args): ...@@ -52,7 +53,7 @@ def main(args):
g = data.graph g = data.graph
# add self loop # add self loop
if args.self_loop: if args.self_loop:
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g.add_edges_from(zip(g.nodes(), g.nodes())) g.add_edges_from(zip(g.nodes(), g.nodes()))
g = DGLGraph(g) g = DGLGraph(g)
......
...@@ -4,6 +4,7 @@ import time ...@@ -4,6 +4,7 @@ import time
import random import random
import numpy as np import numpy as np
import networkx as nx
import sklearn.preprocessing import sklearn.preprocessing
import torch import torch
import torch.nn as nn import torch.nn as nn
...@@ -75,7 +76,7 @@ def main(args): ...@@ -75,7 +76,7 @@ def main(args):
# create GCN model # create GCN model
g = data.graph g = data.graph
if args.self_loop and not args.dataset.startswith('reddit'): if args.self_loop and not args.dataset.startswith('reddit'):
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g.add_edges_from(zip(g.nodes(), g.nodes())) g.add_edges_from(zip(g.nodes(), g.nodes()))
print("adding self-loop edges") print("adding self-loop edges")
g = DGLGraph(g, readonly=True) g = DGLGraph(g, readonly=True)
......
import argparse, time import argparse, time
import numpy as np import numpy as np
import networkx as nx
import torch import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
...@@ -49,7 +50,7 @@ def main(args): ...@@ -49,7 +50,7 @@ def main(args):
g = data.graph g = data.graph
# add self loop # add self loop
if args.self_loop: if args.self_loop:
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g.add_edges_from(zip(g.nodes(), g.nodes())) g.add_edges_from(zip(g.nodes(), g.nodes()))
g = DGLGraph(g) g = DGLGraph(g)
n_edges = g.number_of_edges() n_edges = g.number_of_edges()
......
...@@ -12,6 +12,7 @@ Pytorch implementation: https://github.com/Diego999/pyGAT ...@@ -12,6 +12,7 @@ Pytorch implementation: https://github.com/Diego999/pyGAT
import argparse import argparse
import numpy as np import numpy as np
import networkx as nx
import time import time
import torch import torch
import torch.nn.functional as F import torch.nn.functional as F
...@@ -76,7 +77,7 @@ def main(args): ...@@ -76,7 +77,7 @@ def main(args):
g = data.graph g = data.graph
# add self loop # add self loop
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g = DGLGraph(g) g = DGLGraph(g)
g.add_edges(g.nodes(), g.nodes()) g.add_edges(g.nodes(), g.nodes())
n_edges = g.number_of_edges() n_edges = g.number_of_edges()
......
...@@ -7,6 +7,7 @@ References: ...@@ -7,6 +7,7 @@ References:
""" """
import argparse, time, math import argparse, time, math
import numpy as np import numpy as np
import networkx as nx
import torch import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
...@@ -153,7 +154,7 @@ def main(args): ...@@ -153,7 +154,7 @@ def main(args):
# graph preprocess and calculate normalization factor # graph preprocess and calculate normalization factor
g = data.graph g = data.graph
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g = DGLGraph(g) g = DGLGraph(g)
# add self loop # add self loop
g.add_edges(g.nodes(), g.nodes()) g.add_edges(g.nodes(), g.nodes())
......
import argparse, time import argparse, time
import numpy as np import numpy as np
import networkx as nx
import torch import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
...@@ -62,7 +63,7 @@ def main(args): ...@@ -62,7 +63,7 @@ def main(args):
g = data.graph g = data.graph
# add self loop # add self loop
if args.self_loop: if args.self_loop:
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g.add_edges_from(zip(g.nodes(), g.nodes())) g.add_edges_from(zip(g.nodes(), g.nodes()))
g = DGLGraph(g) g = DGLGraph(g)
n_edges = g.number_of_edges() n_edges = g.number_of_edges()
......
...@@ -8,6 +8,7 @@ import argparse ...@@ -8,6 +8,7 @@ import argparse
import time import time
import abc import abc
import numpy as np import numpy as np
import networkx as nx
import torch import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
...@@ -96,7 +97,7 @@ def main(args): ...@@ -96,7 +97,7 @@ def main(args):
# graph preprocess and calculate normalization factor # graph preprocess and calculate normalization factor
g = data.graph g = data.graph
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g = DGLGraph(g) g = DGLGraph(g)
n_edges = g.number_of_edges() n_edges = g.number_of_edges()
......
...@@ -7,6 +7,7 @@ from dgl import DGLGraph ...@@ -7,6 +7,7 @@ from dgl import DGLGraph
from dgl.data import register_data_args, load_data from dgl.data import register_data_args, load_data
from models import * from models import *
from conf import * from conf import *
import networkx as nx
def get_model_and_config(name): def get_model_and_config(name):
...@@ -82,7 +83,7 @@ def main(args): ...@@ -82,7 +83,7 @@ def main(args):
g = data.graph g = data.graph
# add self loop # add self loop
if args.self_loop: if args.self_loop:
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g.add_edges_from(zip(g.nodes(), g.nodes())) g.add_edges_from(zip(g.nodes(), g.nodes()))
g = DGLGraph(g) g = DGLGraph(g)
n_edges = g.number_of_edges() n_edges = g.number_of_edges()
......
import argparse, time import argparse, time
import numpy as np import numpy as np
import networkx as nx
import torch import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
...@@ -60,8 +61,8 @@ def main(args): ...@@ -60,8 +61,8 @@ def main(args):
g = data.graph g = data.graph
# add self loop # add self loop
if args.self_loop: if args.self_loop:
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g.add_edges_from(zip(g.nodes(), g.nodes())) g.add_edges_from(zip(g.nodes(), g.nodes()))
g = DGLGraph(g) g = DGLGraph(g)
n_edges = g.number_of_edges() n_edges = g.number_of_edges()
......
...@@ -101,6 +101,7 @@ print(net) ...@@ -101,6 +101,7 @@ print(net)
# We load the cora dataset using DGL's built-in data module. # We load the cora dataset using DGL's built-in data module.
from dgl.data import citation_graph as citegrh from dgl.data import citation_graph as citegrh
import networkx as nx
def load_cora_data(): def load_cora_data():
data = citegrh.load_cora() data = citegrh.load_cora()
features = th.FloatTensor(data.features) features = th.FloatTensor(data.features)
...@@ -108,7 +109,7 @@ def load_cora_data(): ...@@ -108,7 +109,7 @@ def load_cora_data():
mask = th.ByteTensor(data.train_mask) mask = th.ByteTensor(data.train_mask)
g = data.graph g = data.graph
# add self loop # add self loop
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g = DGLGraph(g) g = DGLGraph(g)
g.add_edges(g.nodes(), g.nodes()) g.add_edges(g.nodes(), g.nodes())
return g, features, labels, mask return g, features, labels, mask
......
...@@ -274,6 +274,7 @@ class GAT(nn.Module): ...@@ -274,6 +274,7 @@ class GAT(nn.Module):
from dgl import DGLGraph from dgl import DGLGraph
from dgl.data import citation_graph as citegrh from dgl.data import citation_graph as citegrh
import networkx as nx
def load_cora_data(): def load_cora_data():
data = citegrh.load_cora() data = citegrh.load_cora()
...@@ -282,7 +283,7 @@ def load_cora_data(): ...@@ -282,7 +283,7 @@ def load_cora_data():
mask = torch.ByteTensor(data.train_mask) mask = torch.ByteTensor(data.train_mask)
g = data.graph g = data.graph
# add self loop # add self loop
g.remove_edges_from(g.selfloop_edges()) g.remove_edges_from(nx.selfloop_edges(g))
g = DGLGraph(g) g = DGLGraph(g)
g.add_edges(g.nodes(), g.nodes()) g.add_edges(g.nodes(), g.nodes())
return g, features, labels, mask return g, features, labels, mask
......
networkx networkx>=2.1
torch torch
numpy numpy
seaborn seaborn
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment