1111 <img src="https://img.shields.io/badge/Python->=3.7-3776AB?logo=python" alt="Python">
1212 </a >
1313 <a href =" https://github.com/tensorflow/tensorflow/releases/tag/v2.1.0 " >
14- <img src="https://img.shields.io/badge/TensorFlow->=2.1.2 -FF6F00?logo=tensorflow" alt="tensorflow">
14+ <img src="https://img.shields.io/badge/TensorFlow->=2.1.0 -FF6F00?logo=tensorflow" alt="tensorflow">
1515 </a >
1616 <a href =" https://github.com/pytorch/pytorch " >
1717 <img src="https://img.shields.io/badge/PyTorch->=1.5-FF6F00?logo=pytorch" alt="pytorch">
5656Differences between GraphGallery and [ Pytorch Geometric (PyG)] ( https://github.com/rusty1s/pytorch_geometric ) , [ Deep Graph Library (DGL)] ( https://github.com/dmlc/dgl ) , etc...
5757+ PyG and DGL are just like ** TensorFlow** while GraphGallery is more like ** Keras**
5858+ GraphGallery is a plug-and-play and user-friendly toolbox
59- + GraphGallery has high scalaribility for researchers to use
59+ + GraphGallery has high scalaibility for researchers and developers to use
6060
6161
6262# 🚀 Installation
@@ -70,6 +70,14 @@ python setup.py install
7070``` bash
7171pip install -U graphgallery
7272```
73+
74+ GraphGallery has been tested on:
75+ + CUDA 10.1
76+ + TensorFlow 2.1~ 2.3, 2.4 is unavailable now and 2.1.2 is recommended.
77+ + PyTorch 1.5~ 1.7
78+ + Pytorch Geometric (PyG) 1.6.1
79+ + DGL 0.5.2, 0.5.3
80+
7381# 🤖 Implementations
7482Please refer to the [ examples] ( https://github.com/EdisonLeeeee/GraphGallery/blob/master/examples ) directory.
7583
@@ -85,9 +93,9 @@ data = Planetoid('cora', verbose=False)
8593graph = data.graph
8694# here `splits` is a dict like instance
8795splits = data.split_nodes()
88- # splits.trainum_nodes : training indices: 1D Numpy array
96+ # splits.train_nodes : training indices: 1D Numpy array
8997# splits.val_nodes: validation indices: 1D Numpy array
90- # splits.nodes : testing indices: 1D Numpy array
98+ # splits.test_nodes : testing indices: 1D Numpy array
9199>> > graph
92100Graph(adj_matrix(2708 , 2708 ),
93101 node_attr(2708 , 1433 ),
@@ -199,9 +207,9 @@ from graphgallery.gallery import GCN
199207model = GCN(graph, attr_transform = " normalize_attr" , device = " CPU" , seed = 123 )
200208# build your GCN model with default hyper-parameters
201209model.build()
202- # train your model. here splits.trainum_nodes and splits.val_nodes are numpy arrays
210+ # train your model. here splits.train_nodes and splits.val_nodes are numpy arrays
203211# verbose takes 0, 1, 2, 3, 4
204- history = model.train(splits.trainum_nodes , splits.val_nodes, verbose = 1 , epochs = 100 )
212+ history = model.train(splits.train_nodes , splits.val_nodes, verbose = 1 , epochs = 100 )
205213# test your model
206214# verbose takes 0, 1, 2
207215results = model.test(splits.nodes, verbose = 1 )
@@ -210,9 +218,9 @@ print(f'Test loss {results.loss:.5}, Test accuracy {results.accuracy:.2%}')
210218On ` Cora ` dataset:
211219```
212220Training...
213- 100/100 [==============================] - 1s 14ms/step - loss: 1.0161 - acc : 0.9500 - val_loss: 1.4101 - val_acc : 0.7740 - time : 1.4180
221+ 100/100 [==============================] - 1s 14ms/step - loss: 1.0161 - accuracy : 0.9500 - val_loss: 1.4101 - val_accuracy : 0.7740 - Dur. : 1.4180
214222Testing...
215- 1/1 [==============================] - 0s 62ms/step - loss: 1.4123 - acc : 0.8120 - time : 0.0620
223+ 1/1 [==============================] - 0s 62ms/step - loss: 1.4123 - accuracy : 0.8120 - Dur. : 0.0620
216224Test loss 1.4123, Test accuracy 81.20%
217225```
218226## Customization
@@ -232,17 +240,17 @@ you can use the following statement to build your model
232240+ Train your model
233241``` python
234242# train with validation
235- >> > history = model.train(splits.trainum_nodes , splits.val_nodes, verbose = 1 , epochs = 100 )
243+ >> > history = model.train(splits.train_nodes , splits.val_nodes, verbose = 1 , epochs = 100 )
236244# train without validation
237- >> > history = model.train(splits.trainum_nodes , verbose = 1 , epochs = 100 )
245+ >> > history = model.train(splits.train_nodes , verbose = 1 , epochs = 100 )
238246```
239247here ` history ` is a tensorflow ` History ` instance.
240248
241249+ Test you model
242250``` python
243- >> > results = model.test(splits.nodes , verbose = 1 )
251+ >> > results = model.test(splits.test_nodes , verbose = 1 )
244252Testing...
245- 1 / 1 [============================== ] - 0s 62ms / step - loss: 1.4123 - acc : 0.8120 - time : 0.0620
253+ 1 / 1 [============================== ] - 0s 62ms / step - loss: 1.4123 - accuracy : 0.8120 - Dur. : 0.0620
246254>> > print (f ' Test loss { results.loss:.5 } , Test accuracy { results.accuracy:.2% } ' )
247255Test loss 1.4123 , Test accuracy 81.20 %
248256```
@@ -255,7 +263,7 @@ import matplotlib.pyplot as plt
255263with plt.style.context([' science' , ' no-latex' ]):
256264 fig, axes = plt.subplots(1 , 2 , figsize = (15 , 5 ))
257265 axes[0 ].plot(history.history[' accuracy' ], label = ' Training accuracy' , linewidth = 3 )
258- axes[0 ].plot(history.history[' val_accuracy ' ], label = ' Validation accuracy' , linewidth = 3 )
266+ axes[0 ].plot(history.history[' val_accuracyuracy ' ], label = ' Validation accuracy' , linewidth = 3 )
259267 axes[0 ].legend(fontsize = 20 )
260268 axes[0 ].set_title(' Accuracy' , fontsize = 20 )
261269 axes[0 ].set_xlabel(' Epochs' , fontsize = 20 )
@@ -277,7 +285,7 @@ with plt.style.context(['science', 'no-latex']):
277285``` python
278286>> > import graphgallery
279287>> > graphgallery.backend()
280- TensorFlow 2.1 .0 Backend
288+ TensorFlow 2.1 .2 Backend
281289
282290>> > graphgallery.set_backend(" pytorch" )
283291PyTorch 1.6 .0+ cu101 Backend
@@ -290,12 +298,12 @@ PyTorch 1.6.0+cu101 Backend
290298>> > from graphgallery.gallery import GCN
291299>> > model = GCN(graph, attr_transform = " normalize_attr" , device = " GPU" , seed = 123 );
292300>> > model.build()
293- >> > history = model.train(splits.trainum_nodes , splits.val_nodes, verbose = 1 , epochs = 100 )
301+ >> > history = model.train(splits.train_nodes , splits.val_nodes, verbose = 1 , epochs = 100 )
294302Training...
295- 100 / 100 [============================== ] - 0s 5ms / step - loss: 0.6813 - acc : 0.9214 - val_loss: 1.0506 - val_acc : 0.7820 - time : 0.4734
296- >> > results = model.test(splits.nodes , verbose = 1 )
303+ 100 / 100 [============================== ] - 0s 5ms / step - loss: 0.6813 - accuracy : 0.9214 - val_loss: 1.0506 - val_accuracy : 0.7820 - Dur. : 0.4734
304+ >> > results = model.test(splits.test_nodes , verbose = 1 )
297305Testing...
298- 1 / 1 [============================== ] - 0s 1ms / step - loss: 1.0131 - acc : 0.8220 - time : 0.0013
306+ 1 / 1 [============================== ] - 0s 1ms / step - loss: 1.0131 - accuracy : 0.8220 - Dur. : 0.0013
299307>> > print (f ' Test loss { results.loss:.5 } , Test accuracy { results.accuracy:.2% } ' )
300308Test loss 1.0131 , Test accuracy 82.20 %
301309
@@ -342,18 +350,22 @@ PyTorch Geometric 1.6.1 (PyTorch 1.6.0+cu101) Backend
342350>> > from graphgallery.gallery import GCN
343351>> > model = GCN(graph, attr_transform = " normalize_attr" , device = " GPU" , seed = 123 );
344352>> > model.build()
345- >> > history = model.train(splits.trainum_nodes , splits.val_nodes, verbose = 1 , epochs = 100 )
353+ >> > history = model.train(splits.train_nodes , splits.val_nodes, verbose = 1 , epochs = 100 )
346354Training...
347- 100 / 100 [============================== ] - 0s 3ms / step - loss: 0.5325 - acc : 0.9643 - val_loss: 1.0034 - val_acc : 0.7980 - time : 0.3101
348- >> > results = model.test(splits.nodes , verbose = 1 )
355+ 100 / 100 [============================== ] - 0s 3ms / step - loss: 0.5325 - accuracy : 0.9643 - val_loss: 1.0034 - val_accuracy : 0.7980 - Dur. : 0.3101
356+ >> > results = model.test(splits.test_nodes , verbose = 1 )
349357Testing...
350- 1 / 1 [============================== ] - 0s 834us / step - loss: 0.9733 - acc : 0.8130 - time : 8.2737e-04
358+ 1 / 1 [============================== ] - 0s 834us / step - loss: 0.9733 - accuracy : 0.8130 - Dur. : 8.2737e-04
351359>> > print (f ' Test loss { results.loss:.5 } , Test accuracy { results.accuracy:.2% } ' )
352360Test loss 0.97332 , Test accuracy 81.30 %
353361```
354362similarly, you can use DGL backend just by:
355363``` python
364+ # DGL PyTorch backend
356365>> > graphgallery.set_backend(" dgl" )
366+ # DGL TensorFlow backend
367+ >> > graphgallery.set_backend(" dgl-tf" )
368+
357369```
358370
359371
@@ -365,7 +377,7 @@ similarly, you can use DGL backend just by:
365377- [ ] Support for more tasks, e.g., ` graph Classification ` and ` link prediction `
366378- [x] Support for more types of graphs, e.g., Heterogeneous graph
367379- [ ] Add Docstrings and Documentation (Building)
368-
380+ - [ ] Comprehensive tutorials
369381
370382# 😘 Acknowledgement
371383This project is motivated by [ Pytorch Geometric] ( https://github.com/rusty1s/pytorch_geometric ) , [ Tensorflow Geometric] ( https://github.com/CrawlScript/tf_geometric ) , [ Stellargraph] ( https://github.com/stellargraph/stellargraph ) and [ DGL] ( https://github.com/dmlc/dgl ) , etc., and the original implementations of the authors, thanks for their excellent works!
0 commit comments