repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
spektral
spektral-master/spektral/layers/convolutional/general_conv.py
import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras.layers import BatchNormalization, Dropout, PReLU from spektral.layers.convolutional.message_passing import MessagePassing class GeneralConv(MessagePassing): r""" A general convolutional layer from the paper > [Design ...
5,435
32.975
84
py
spektral
spektral-master/spektral/layers/convolutional/gin_conv.py
import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras.layers import BatchNormalization, Dense from tensorflow.keras.models import Sequential from spektral.layers import ops from spektral.layers.convolutional.message_passing import MessagePassing class GINConv(MessagePassing): r""...
5,345
32.4125
86
py
spektral
spektral-master/spektral/layers/convolutional/graphsage_conv.py
from tensorflow.keras import backend as K from spektral.layers import ops from spektral.layers.convolutional.message_passing import MessagePassing class GraphSageConv(MessagePassing): r""" A GraphSAGE layer from the paper > [Inductive Representation Learning on Large Graphs](https://arxiv.org/abs/1706.0...
3,941
31.04878
95
py
spektral
spektral-master/spektral/layers/convolutional/edge_conv.py
from tensorflow.keras import activations from tensorflow.keras import backend as K from tensorflow.keras.layers import Dense from tensorflow.keras.models import Sequential from spektral.layers.convolutional.message_passing import MessagePassing class EdgeConv(MessagePassing): r""" An edge convolutional layer...
4,206
31.612403
92
py
spektral
spektral-master/spektral/layers/convolutional/gated_graph_conv.py
import tensorflow as tf from tensorflow.keras.layers import GRUCell from spektral.layers.convolutional.message_passing import MessagePassing class GatedGraphConv(MessagePassing): r""" A gated graph convolutional layer from the paper > [Gated Graph Sequence Neural Networks](https://arxiv.org/abs/1511.054...
4,254
32.242188
82
py
spektral
spektral-master/spektral/layers/convolutional/ecc_conv.py
import warnings import tensorflow as tf from tensorflow.keras import backend as K from tensorflow.keras.layers import Dense from spektral.layers import ops from spektral.layers.convolutional.conv import Conv from spektral.layers.ops import modes class ECCConv(Conv): r""" An edge-conditioned convolutional ...
6,994
34.871795
82
py
spektral
spektral-master/spektral/layers/convolutional/gcn_conv.py
from tensorflow.keras import backend as K from spektral.layers import ops from spektral.layers.convolutional.conv import Conv from spektral.utils import gcn_filter class GCNConv(Conv): r""" A graph convolutional layer (GCN) from the paper > [Semi-Supervised Classification with Graph Convolutional Networ...
3,695
30.322034
110
py
spektral
spektral-master/spektral/layers/convolutional/gtv_conv.py
import tensorflow as tf from tensorflow.keras import backend as K from spektral.layers import ops from spektral.layers.convolutional.conv import Conv class GTVConv(Conv): r""" A graph total variation convolutional layer (GTVConv) from the paper > [Total Variation Graph Neural Networks](https://arxiv.org...
6,767
30.774648
121
py
spektral
spektral-master/spektral/layers/convolutional/gcs_conv.py
from tensorflow.keras import backend as K from spektral.layers import ops from spektral.layers.convolutional.conv import Conv from spektral.utils import normalized_adjacency class GCSConv(Conv): r""" A `GraphConv` layer with a trainable skip connection. **Mode**: single, disjoint, mixed, batch. Thi...
3,852
29.824
89
py
spektral
spektral-master/spektral/layers/convolutional/crystal_conv.py
from tensorflow.keras import backend as K from tensorflow.keras.layers import Dense from spektral.layers.convolutional.message_passing import MessagePassing class CrystalConv(MessagePassing): r""" A crystal graph convolutional layer from the paper > [Crystal Graph Convolutional Neural Networks for an Ac...
3,725
32.567568
90
py
spektral
spektral-master/spektral/layers/convolutional/censnet_conv.py
import tensorflow as tf from spektral.layers import ops from spektral.layers.convolutional.conv import Conv from spektral.utils.convolution import gcn_filter, incidence_matrix, line_graph class CensNetConv(Conv): r""" A CensNet convolutional layer from the paper > [Co-embedding of Nodes and Edges with G...
10,489
39.346154
104
py
spektral
spektral-master/spektral/layers/convolutional/__init__.py
from .agnn_conv import AGNNConv from .appnp_conv import APPNPConv from .arma_conv import ARMAConv from .censnet_conv import CensNetConv from .cheb_conv import ChebConv from .crystal_conv import CrystalConv from .diffusion_conv import DiffusionConv from .ecc_conv import ECCConv from .edge_conv import EdgeConv from .gat_...
723
33.47619
49
py
spektral
spektral-master/spektral/layers/convolutional/conv.py
import warnings from functools import wraps import tensorflow as tf from tensorflow.keras.layers import Layer from spektral.utils.keras import ( deserialize_kwarg, is_keras_kwarg, is_layer_kwarg, serialize_kwarg, ) class Conv(Layer): r""" A general class for convolutional layers. You ca...
2,918
26.280374
86
py
spektral
spektral-master/spektral/layers/convolutional/tag_conv.py
from tensorflow.keras import backend as K from tensorflow.keras.layers import Dense from spektral.layers.convolutional.message_passing import MessagePassing from spektral.utils import normalized_adjacency class TAGConv(MessagePassing): r""" A Topology Adaptive Graph Convolutional layer (TAG) from the paper ...
3,772
29.92623
92
py
spektral
spektral-master/spektral/layers/convolutional/message_passing.py
import inspect import tensorflow as tf from tensorflow.keras import backend as K from tensorflow.keras.layers import Layer from spektral.layers.ops.scatter import deserialize_scatter, serialize_scatter from spektral.utils.keras import ( deserialize_kwarg, is_keras_kwarg, is_layer_kwarg, serialize_kwar...
7,175
34.176471
90
py
spektral
spektral-master/spektral/layers/convolutional/gat_conv.py
import tensorflow as tf from tensorflow.keras import backend as K from tensorflow.keras import constraints, initializers, regularizers from tensorflow.keras.layers import Dropout from spektral.layers import ops from spektral.layers.convolutional.conv import Conv from spektral.layers.ops import modes class GATConv(Co...
10,279
36.933579
85
py
spektral
spektral-master/spektral/layers/ops/sparse.py
import tensorflow as tf from tensorflow.python.ops import gen_sparse_ops from . import ops def add_self_loops(a, fill=1.0): """ Adds self-loops to the given adjacency matrix. Self-loops are added only for those node that don't have a self-loop already, and are assigned a weight of `fill`. :param ...
7,920
36.719048
85
py
spektral
spektral-master/spektral/layers/ops/modes.py
import tensorflow as tf from tensorflow.keras import backend as K SINGLE = 1 # Single mode rank(x) = 2, rank(a) = 2 DISJOINT = SINGLE # Disjoint mode rank(x) = 2, rank(a) = 2 BATCH = 3 # Batch mode rank(x) = 3, rank(a) = 3 MIXED = 4 # Mixed mode rank(x) = 3, rank(a) = 2 def disjoint_signal_to_batch(X...
3,567
32.345794
89
py
spektral
spektral-master/spektral/layers/ops/graph.py
import tensorflow as tf from tensorflow.keras import backend as K from . import ops def normalize_A(A): """ Computes symmetric normalization of A, dealing with sparse A and batch mode automatically. :param A: Tensor or SparseTensor with rank k = {2, 3}. :return: Tensor or SparseTensor of rank k. ...
2,116
29.242857
82
py
spektral
spektral-master/spektral/layers/ops/scatter.py
import tensorflow as tf def mixed_mode_support(scatter_fn): def _wrapper_mm_support(updates, indices, N): if len(updates.shape) == 3: updates = tf.transpose(updates, perm=(1, 0, 2)) out = scatter_fn(updates, indices, N) if len(out.shape) == 3: out = tf.transpose(out...
8,807
38.497758
87
py
spektral
spektral-master/spektral/layers/ops/matmul.py
import tensorflow as tf from tensorflow.keras import backend as K from tensorflow.python.ops.linalg.sparse import sparse as tfsp from . import ops def dot(a, b): """ Computes a @ b, for a, b of the same rank (both 2 or both 3). If the rank is 2, then the innermost dimension of `a` must match the out...
6,354
33.726776
81
py
spektral
spektral-master/spektral/layers/ops/__init__.py
from .graph import * from .matmul import * from .modes import * from .ops import * from .scatter import * from .sparse import *
128
17.428571
22
py
spektral
spektral-master/spektral/layers/ops/ops.py
import numpy as np import tensorflow as tf from tensorflow.keras import backend as K def transpose(a, perm=None, name=None): """ Transposes a according to perm, dealing automatically with sparsity. :param a: Tensor or SparseTensor with rank k. :param perm: permutation indices of size k. :param nam...
3,729
34.52381
78
py
spektral
spektral-master/spektral/utils/keras.py
from tensorflow.keras import activations, constraints, initializers, regularizers LAYER_KWARGS = {"activation", "use_bias"} KERAS_KWARGS = { "trainable", "name", "dtype", "dynamic", "input_dim", "input_shape", "batch_input_shape", "batch_size", "weights", "activity_regularizer",...
1,372
23.517857
81
py
spektral
spektral-master/spektral/utils/sparse.py
import numpy as np import tensorflow as tf from scipy import sparse as sp def reorder(edge_index, edge_weight=None, edge_features=None): """ Reorders `edge_index`, `edge_weight`, and `edge_features` according to the row-major ordering of `edge_index`. :param edge_index: np.array of shape `[n_edges, 2]...
2,843
34.111111
88
py
spektral
spektral-master/spektral/utils/logging.py
import os import time from pprint import pformat LOGFILE = None TIME_STACK = [] def init_logging(name=None): """ Creates a log directory with an empty log.txt file. :param name: custom name for the log directory (default \"%Y-%m-%d-%H-%M-%S\") :return: string, the relative path to the log directory ...
2,314
26.891566
82
py
spektral
spektral-master/spektral/utils/misc.py
import numpy as np def pad_jagged_array(x, target_shape): """ Given a jagged array of arbitrary dimensions, zero-pads all elements in the array to match the provided `target_shape`. :param x: a list or np.array of dtype object, containing np.arrays with variable dimensions; :param target_shape...
2,923
32.227273
81
py
spektral
spektral-master/spektral/utils/convolution.py
import copy import warnings from functools import partial import numpy as np import tensorflow as tf from scipy import linalg from scipy import sparse as sp from scipy.sparse.linalg import ArpackNoConvergence def degree_matrix(A): """ Computes the degree matrix of the given adjacency matrix. :param A: ra...
11,683
33.26393
88
py
spektral
spektral-master/spektral/utils/__init__.py
from .convolution import * from .io import * from .logging import * from .misc import * from .sparse import *
110
17.5
26
py
spektral
spektral-master/spektral/utils/io.py
import ast import sys import joblib import networkx as nx import numpy as np import pandas as pd import scipy.sparse as sp from spektral.data.graph import Graph def load_binary(filename): """ Loads a pickled file. :param filename: a string or file-like object :return: the loaded object """ t...
12,804
24.921053
114
py
spektral
spektral-master/spektral/data/loaders.py
import numpy as np import tensorflow as tf from spektral.data.utils import ( batch_generator, collate_labels_batch, collate_labels_disjoint, get_spec, prepend_none, sp_matrices_to_sp_tensors, to_batch, to_disjoint, to_mixed, to_tf_signature, ) version = tf.__version__.split("."...
21,819
33.416404
88
py
spektral
spektral-master/spektral/data/utils.py
import numpy as np import tensorflow as tf from scipy import sparse as sp from spektral.utils import pad_jagged_array from spektral.utils.sparse import sp_matrix_to_sp_tensor def to_disjoint(x_list=None, a_list=None, e_list=None): """ Converts lists of node features, adjacency matrices and edge features to ...
10,658
34.768456
88
py
spektral
spektral-master/spektral/data/dataset.py
import copy import os.path as osp import warnings import numpy as np import tensorflow as tf from spektral.data.graph import Graph from spektral.data.utils import get_spec from spektral.datasets.utils import DATASET_FOLDER class Dataset: """ A container for Graph objects. This class can be extended to repre...
10,277
33.840678
84
py
spektral
spektral-master/spektral/data/graph.py
import warnings import numpy as np import scipy.sparse as sp class Graph: """ A container to represent a graph. The data associated with the Graph is stored in its attributes: - `x`, for the node features; - `a`, for the adjacency matrix; - `e`, for the edge attributes; -...
5,610
33.006061
117
py
spektral
spektral-master/spektral/data/__init__.py
from .dataset import Dataset from .graph import Graph from .loaders import ( BatchLoader, DisjointLoader, Loader, MixedLoader, PackedBatchLoader, SingleLoader, )
186
16
28
py
spektral
spektral-master/spektral/transforms/one_hot.py
from spektral.utils import label_to_one_hot, one_hot class OneHotLabels: """ One-hot encodes the graph labels along the innermost dimension (also if they are simple scalars). Either `depth` or `labels` must be passed as argument. **Arguments** - `depth`: int, the size of the one-hot vector ...
996
30.15625
80
py
spektral
spektral-master/spektral/transforms/gcn_filter.py
from spektral.utils import gcn_filter class GCNFilter: r""" Normalizes the adjacency matrix as described by [Kipf & Welling (2017)](https://arxiv.org/abs/1609.02907): $$ \A \leftarrow \hat\D^{-\frac{1}{2}} (\A + \I) \hat\D^{-\frac{1}{2}} $$ where \( \hat\D_{ii} = 1 + \...
692
24.666667
84
py
spektral
spektral-master/spektral/transforms/constant.py
import numpy as np class Constant: """ Concatenates a constant value to the node attributes. **Arguments** - `value`: the value to concatenate to the node attributes. """ def __init__(self, value): self.value = value def __call__(self, graph): value = np.zeros((graph.n_...
500
19.875
63
py
spektral
spektral-master/spektral/transforms/layer_preprocess.py
class LayerPreprocess(object): """ Applies the `preprocess` function of a convolutional Layer to the adjacency matrix. **Arguments** - `layer_class`: the class of a layer from `spektral.layers.convolutional`, or any Layer that implements a `preprocess(adj)` method. """ def __init__(se...
566
27.35
79
py
spektral
spektral-master/spektral/transforms/laplacian_pe.py
import numpy as np from scipy.sparse.linalg import eigsh from spektral.utils import normalized_laplacian class LaplacianPE: r""" Adds Laplacian positional encodings to the nodes. The first `k` eigenvectors are computed and concatenated to the node features. Each node will be extended with its corres...
992
26.583333
82
py
spektral
spektral-master/spektral/transforms/normalize_adj.py
from spektral.utils import normalized_adjacency class NormalizeAdj: r""" Normalizes the adjacency matrix as: $$ \A \leftarrow \D^{-1/2}\A\D^{-1/2} $$ **Arguments** - `symmetric`: If False, then it computes \(\D^{-1}\A\) instead. """ def __init__(self, symmetr...
519
20.666667
72
py
spektral
spektral-master/spektral/transforms/adj_to_sp_tensor.py
from spektral.utils.sparse import sp_matrix_to_sp_tensor class AdjToSpTensor: """ Converts the adjacency matrix to a SparseTensor. """ def __call__(self, graph): if graph.a is not None: graph.a = sp_matrix_to_sp_tensor(graph.a) return graph
289
19.714286
56
py
spektral
spektral-master/spektral/transforms/degree.py
import numpy as np from spektral.utils import one_hot class Degree: """ Concatenates to each node attribute the one-hot degree of the corresponding node. The adjacency matrix is expected to have integer entries and the degree is cast to integer before one-hot encoding. **Arguments** - ...
1,056
24.780488
79
py
spektral
spektral-master/spektral/transforms/__init__.py
from .adj_to_sp_tensor import AdjToSpTensor from .clustering_coefficient import ClusteringCoeff from .constant import Constant from .degree import Degree from .delaunay import Delaunay from .gcn_filter import GCNFilter from .laplacian_pe import LaplacianPE from .layer_preprocess import LayerPreprocess from .normalize_a...
463
34.692308
51
py
spektral
spektral-master/spektral/transforms/normalize_sphere.py
import numpy as np class NormalizeSphere: r""" Normalizes the node attributes so that they are centered at the origin and contained within a sphere of radius 1: $$ \X_{i} \leftarrow \frac{\X_{i} - \bar\X}{\max_{i,j} \X_{ij}} $$ where \( \bar\X \) is the centroid of...
538
24.666667
82
py
spektral
spektral-master/spektral/transforms/normalize_one.py
import numpy as np class NormalizeOne: r""" Normalizes the node attributes by dividing each row by its sum, so that it sums to 1: $$ \X_i \leftarrow \frac{\X_i}{\sum_{j=1}^{N} \X_{ij}} $$ """ def __call__(self, graph): x_sum = np.sum(graph.x, -1) x_sum[x_sum == 0]...
392
18.65
78
py
spektral
spektral-master/spektral/transforms/clustering_coefficient.py
import networkx as nx import numpy as np class ClusteringCoeff: """ Concatenates to each node attribute the clustering coefficient of the corresponding node. """ def __call__(self, graph): if "a" not in graph: raise ValueError("The graph must have an adjacency matrix") ...
673
25.96
74
py
spektral
spektral-master/spektral/transforms/delaunay.py
import numpy as np import scipy.sparse as sp from scipy.spatial import Delaunay as DelaunaySP class Delaunay: """ Computes the Delaunay triangulation of the node features. The adjacency matrix is obtained from the edges of the triangulation and replaces the previous adjacency matrix. Duplicate ed...
1,022
30.96875
84
py
spektral
spektral-master/examples/other/explain_graph_predictions.py
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from tensorflow.keras.losses import CategoricalCrossentropy from tensorflow.keras.metrics import categorical_accuracy from tensorflow.keras.optimizers import Adam from spektral.data import DisjointLoader from spektral.datasets import TUDataset ...
2,857
29.084211
86
py
spektral
spektral-master/examples/other/explain_node_predictions.py
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from tensorflow.keras.callbacks import EarlyStopping from tensorflow.keras.losses import CategoricalCrossentropy from tensorflow.keras.optimizers import Adam from spektral.data.loaders import SingleLoader from spektral.datasets.citation import ...
2,137
28.694444
81
py
spektral
spektral-master/examples/other/node_clustering_mincut.py
""" This example implements the experiments for node clustering on citation networks from the paper: Mincut pooling in Graph Neural Networks (https://arxiv.org/abs/1907.00481) Filippo Maria Bianchi, Daniele Grattarola, Cesare Alippi """ import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from s...
3,447
30.345455
85
py
spektral
spektral-master/examples/other/graph_signal_classification_mnist.py
import numpy as np import tensorflow as tf from tensorflow.keras import Model from tensorflow.keras.layers import Dense from tensorflow.keras.losses import SparseCategoricalCrossentropy from tensorflow.keras.metrics import sparse_categorical_accuracy from tensorflow.keras.optimizers import Adam from tensorflow.keras.re...
4,254
30.058394
81
py
spektral
spektral-master/examples/other/node_clustering_tvgnn.py
""" This example implements the node clustering experiment on citation networks from the paper: Total Variation Graph Neural Networks (https://arxiv.org/abs/2211.06218) Jonas Berg Hansen and Filippo Maria Bianchi """ import numpy as np import tensorflow as tf from sklearn.metrics.cluster import ( completeness_sco...
3,374
23.816176
85
py
spektral
spektral-master/examples/graph_prediction/ogbg-mol-hiv_ecc.py
""" This example shows how to perform molecule classification with the [Open Graph Benchmark](https://ogb.stanford.edu) `mol-hiv` dataset, using a simple ECC-based GNN in disjoint mode. The model does not perform really well but should give you a starting point if you want to implement a more sophisticated one. """ im...
3,971
34.783784
86
py
spektral
spektral-master/examples/graph_prediction/qm9_ecc_batch.py
""" This example shows how to perform regression of molecular properties with the QM9 database, using a GNN based on edge-conditioned convolutions in batch mode. """ import numpy as np from tensorflow.keras.layers import Dense from tensorflow.keras.models import Model from tensorflow.keras.optimizers import Adam from...
2,883
35.506329
85
py
spektral
spektral-master/examples/graph_prediction/custom_dataset.py
""" This example shows how to define your own dataset and use it to train a non-trivial GNN with message-passing and pooling layers. The script also shows how to implement fast training and evaluation functions in disjoint mode, with early stopping and accuracy monitoring. The dataset that we create is a simple synthe...
6,894
33.133663
94
py
spektral
spektral-master/examples/graph_prediction/tud_mincut.py
import numpy as np from tensorflow.keras.callbacks import EarlyStopping from tensorflow.keras.layers import Dense from tensorflow.keras.models import Model from tensorflow.keras.optimizers import Adam from spektral.data import BatchLoader from spektral.datasets import TUDataset from spektral.layers import GCSConv, Glo...
3,272
35.775281
80
py
spektral
spektral-master/examples/graph_prediction/general_gnn.py
""" This example implements the model from the paper > [Design Space for Graph Neural Networks](https://arxiv.org/abs/2011.08843)<br> > Jiaxuan You, Rex Ying, Jure Leskovec using the PROTEINS dataset. The configuration at the top of the file is the best one identified in the paper, and should work well for m...
3,934
34.133929
96
py
spektral
spektral-master/examples/graph_prediction/tud_gin.py
""" This example shows how to perform graph classification with a simple Graph Isomorphism Network. """ import numpy as np import tensorflow as tf from tensorflow.keras.layers import Dense, Dropout from tensorflow.keras.losses import CategoricalCrossentropy from tensorflow.keras.metrics import categorical_accuracy fro...
4,168
33.741667
86
py
spektral
spektral-master/examples/graph_prediction/qm9_ecc.py
""" This example shows how to perform regression of molecular properties with the QM9 database, using a simple GNN in disjoint mode. """ import numpy as np import tensorflow as tf from tensorflow.keras import Model from tensorflow.keras.layers import Dense from tensorflow.keras.losses import MeanSquaredError from tens...
3,524
33.223301
86
py
spektral
spektral-master/examples/node_prediction/citation_gat_custom.py
""" This script is an extension of the citation_gcn_custom.py script. It shows how to train GAT (with the same experimental setting of the original paper), using faster training and test functions. """ import tensorflow as tf from tensorflow.keras.layers import Dropout, Input from tensorflow.keras.losses import Catego...
3,234
28.144144
88
py
spektral
spektral-master/examples/node_prediction/citation_gcn.py
""" This example implements the experiments on citation networks from the paper: Semi-Supervised Classification with Graph Convolutional Networks (https://arxiv.org/abs/1609.02907) Thomas N. Kipf, Max Welling """ import numpy as np import tensorflow as tf from tensorflow.keras.callbacks import EarlyStopping from tenso...
2,097
30.313433
99
py
spektral
spektral-master/examples/node_prediction/citation_cheby.py
""" This example implements the experiments on citation networks from the paper: Semi-Supervised Classification with Graph Convolutional Networks (https://arxiv.org/abs/1609.02907) Thomas N. Kipf, Max Welling using the convolutional layers described in: Convolutional Neural Networks on Graphs with Fast Localized Spe...
3,207
33.494624
113
py
spektral
spektral-master/examples/node_prediction/citation_arma.py
""" This example implements the experiments on citation networks from the paper: Graph Neural Networks with convolutional ARMA filters (https://arxiv.org/abs/1901.01343) Filippo Maria Bianchi, Daniele Grattarola, Cesare Alippi, Lorenzo Livi """ from tensorflow.keras.callbacks import EarlyStopping from tensorflow.kera...
3,057
32.604396
88
py
spektral
spektral-master/examples/node_prediction/citation_gcn_custom.py
""" This script is a proof of concept to train GCN as fast as possible and with as little lines of code as possible. It uses a custom training function instead of the standard Keras fit(), and can train GCN for 200 epochs in a few tenths of a second (~0.20 on a GTX 1050). """ import tensorflow as tf from tensorflow.ker...
1,637
32.428571
88
py
spektral
spektral-master/examples/node_prediction/citation_simple_gc.py
""" This example implements the experiments on citation networks from the paper: Simplifying Graph Convolutional Networks (https://arxiv.org/abs/1902.07153) Felix Wu, Tianyi Zhang, Amauri Holanda de Souza Jr., Christopher Fifty, Tao Yu, Kilian Q. Weinberger To implement it, we define a custom transform for the adjace...
2,774
31.267442
100
py
spektral
spektral-master/examples/node_prediction/ogbn-arxiv_gcn.py
""" This example implements the same GCN example for node classification provided with the [Open Graph Benchmark](https://ogb.stanford.edu). See https://github.com/snap-stanford/ogb/blob/master/examples/nodeproppred/arxiv/gnn.py for the reference implementation. """ import numpy as np import tensorflow as tf from ogb.n...
3,535
33
87
py
spektral
spektral-master/examples/node_prediction/citation_gat.py
""" This example implements the experiments on citation networks from the paper: Graph Attention Networks (https://arxiv.org/abs/1710.10903) Petar Veličković, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, Yoshua Bengio """ import numpy as np from tensorflow.keras.callbacks import EarlyStopping from t...
3,212
30.194175
95
py
spektral
spektral-master/tests/test_datasets.py
from spektral import datasets from spektral.data import BatchLoader, DisjointLoader, SingleLoader batch_size = 3 def test_citation(): dataset = datasets.Cora() dataset = datasets.Citeseer(random_split=True) dataset = datasets.Pubmed(normalize_x=True) sl = SingleLoader(dataset) sl.load() def tes...
1,702
22.328767
68
py
spektral
spektral-master/tests/__init__.py
0
0
0
py
spektral
spektral-master/tests/test_layers/test_ops.py
import numpy as np import scipy.sparse as sp import tensorflow as tf from spektral.data.utils import to_disjoint from spektral.layers import ops from spektral.utils import convolution from spektral.utils.sparse import sp_batch_to_sp_tensor, sp_matrix_to_sp_tensor batch_size = 10 N = 3 M = 5 tol = 1e-5 def _assert_a...
14,358
32.627635
88
py
spektral
spektral-master/tests/test_layers/__init__.py
0
0
0
py
spektral
spektral-master/tests/test_layers/test_base.py
import numpy as np import scipy.sparse as sp import tensorflow as tf from spektral import layers from spektral.utils.sparse import sp_matrix_to_sp_tensor from tests.test_layers.convolutional.core import _test_get_config tol = 1e-6 def test_disjoint_2_batch(): X = np.array([[1, 0], [0, 1], [1, 1], [0, 0], [1, 2]...
2,107
28.277778
85
py
spektral
spektral-master/tests/test_layers/pooling/test_diff_pool.py
from spektral import layers from tests.test_layers.pooling.core import MODES, run_layer config = { "layer": layers.DiffPool, "modes": [MODES["SINGLE"], MODES["BATCH"]], "kwargs": {"k": 5, "return_selection": True}, "dense": True, "sparse": True, } def test_layer(): run_layer(config)
311
19.8
59
py
spektral
spektral-master/tests/test_layers/pooling/core.py
import numpy as np import scipy.sparse as sp import tensorflow as tf from tensorflow.keras import Input, Model from spektral.utils.sparse import sp_matrix_to_sp_tensor from tests.test_layers.convolutional.core import _test_get_config tf.keras.backend.set_floatx("float64") MODES = { "SINGLE": 0, "BATCH": 1, ...
5,234
29.086207
85
py
spektral
spektral-master/tests/test_layers/pooling/test_topk_pool.py
from spektral import layers from tests.test_layers.pooling.core import MODES, run_layer config = { "layer": layers.TopKPool, "modes": [MODES["SINGLE"], MODES["DISJOINT"]], "kwargs": {"ratio": 0.5, "return_selection": True}, "dense": False, "sparse": True, } def test_layer(): run_layer(config)...
321
20.466667
59
py
spektral
spektral-master/tests/test_layers/pooling/test_sag_pool.py
from spektral import layers from tests.test_layers.pooling.core import MODES, run_layer config = { "layer": layers.SAGPool, "modes": [MODES["SINGLE"], MODES["DISJOINT"]], "kwargs": {"ratio": 0.5, "return_selection": True}, "dense": False, "sparse": True, } def test_layer(): run_layer(config)
320
20.4
59
py
spektral
spektral-master/tests/test_layers/pooling/test_dmon_pool.py
from spektral import layers from tests.test_layers.pooling.core import MODES, run_layer config = { "layer": layers.DMoNPool, "modes": [MODES["SINGLE"], MODES["BATCH"]], "kwargs": {"k": 5, "return_selection": True}, "dense": True, "sparse": True, } def test_layer(): run_layer(config)
311
19.8
59
py
spektral
spektral-master/tests/test_layers/pooling/test_global_pooling.py
import numpy as np import tensorflow as tf from tensorflow.keras import Input, Model from spektral.layers import ( GlobalAttentionPool, GlobalAttnSumPool, GlobalAvgPool, GlobalMaxPool, GlobalSumPool, SortPool, ) from tests.test_layers.convolutional.core import _test_get_config tf.keras.backend...
4,319
30.304348
87
py
spektral
spektral-master/tests/test_layers/pooling/test_asym_cheeger_cut_pool.py
from spektral import layers from tests.test_layers.pooling.core import MODES, run_layer config = { "layer": layers.AsymCheegerCutPool, "modes": [MODES["SINGLE"], MODES["BATCH"]], "kwargs": { "k": 5, "return_selection": True, "mlp_hidden": [32], "totvar_coeff": 1.0, "...
431
19.571429
59
py
spektral
spektral-master/tests/test_layers/pooling/test_la_pool.py
from spektral import layers from tests.test_layers.pooling.core import MODES, run_layer config = { "layer": layers.LaPool, "modes": [MODES["SINGLE"], MODES["DISJOINT"]], "kwargs": {"return_selection": True}, "dense": False, "sparse": True, } def test_layer(): run_layer(config)
305
19.4
59
py
spektral
spektral-master/tests/test_layers/pooling/test_mincut_pool.py
from spektral import layers from tests.test_layers.pooling.core import MODES, run_layer config = { "layer": layers.MinCutPool, "modes": [MODES["SINGLE"], MODES["BATCH"]], "kwargs": {"k": 5, "return_selection": True, "mlp_hidden": [32]}, "dense": True, "sparse": True, } def test_layer(): run_l...
333
21.266667
69
py
spektral
spektral-master/tests/test_layers/pooling/test_just_balance_pool.py
from spektral import layers from tests.test_layers.pooling.core import MODES, run_layer config = { "layer": layers.JustBalancePool, "modes": [MODES["SINGLE"], MODES["BATCH"]], "kwargs": {"k": 5, "return_selection": True}, "dense": True, "sparse": True, } def test_layer(): run_layer(config)
318
20.266667
59
py
spektral
spektral-master/tests/test_layers/convolutional/test_censnet_conv.py
import enum import networkx as nx import numpy as np import pytest from core import A, F, S, batch_size from tensorflow.keras import Input, Model from spektral.layers import CensNetConv NODE_CHANNELS = 8 """ Number of node output channels to use for testing. """ EDGE_CHANNELS = 10 """ Number of edge output channels ...
6,138
30.64433
83
py
spektral
spektral-master/tests/test_layers/convolutional/test_gcs_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.GCSConv, "modes": [MODES["SINGLE"], MODES["BATCH"], MODES["MIXED"]], "kwargs": {"channels": 8, "activation": "relu"}, "dense": True, "sparse": True, "edges": False, } def test_layer(): run_layer(conf...
324
18.117647
63
py
spektral
spektral-master/tests/test_layers/convolutional/test_gin_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.GINConv, "modes": [MODES["SINGLE"], MODES["MIXED"]], "kwargs": {"channels": 8, "activation": "relu", "mlp_hidden": [16]}, "dense": False, "sparse": True, "edges": False, } def test_layer(): run_layer...
389
19.526316
72
py
spektral
spektral-master/tests/test_layers/convolutional/test_tag_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.TAGConv, "modes": [MODES["SINGLE"], MODES["MIXED"]], "kwargs": {"channels": 7, "K": 3}, "dense": False, "sparse": True, "edges": False, } def test_layer(): run_layer(config)
295
16.411765
47
py
spektral
spektral-master/tests/test_layers/convolutional/test_message_passing.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.MessagePassing, "modes": [MODES["SINGLE"], MODES["MIXED"]], "kwargs": {"channels": 7}, "dense": False, "sparse": True, "edges": False, } def test_layer(): run_layer(config)
294
16.352941
47
py
spektral
spektral-master/tests/test_layers/convolutional/core.py
import itertools import numpy as np import tensorflow as tf from tensorflow.keras import Input, Model from spektral.utils.sparse import sp_matrix_to_sp_tensor tf.keras.backend.set_floatx("float64") MODES = { "SINGLE": 0, "BATCH": 1, "MIXED": 2, } batch_size = 32 N = 11 F = 7 S = 3 A = np.ones((N, N)) X ...
7,676
28.413793
87
py
spektral
spektral-master/tests/test_layers/convolutional/test_xenet_conv.py
import numpy as np from tensorflow.keras.layers import Input from tensorflow.keras.models import Model from spektral.layers import XENetConv, XENetConvBatch from spektral.utils.sparse import sp_matrix_to_sp_tensor # Not using these tests because they assume certain behaviors that we # don't follow """ dense_config = ...
6,662
32.822335
124
py
spektral
spektral-master/tests/test_layers/convolutional/test_gated_graph_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.GatedGraphConv, "modes": [MODES["SINGLE"], MODES["MIXED"]], "kwargs": {"channels": 10, "n_layers": 3}, "dense": False, "sparse": True, "edges": False, } def test_layer(): run_layer(config)
310
17.294118
47
py
spektral
spektral-master/tests/test_layers/convolutional/test_appnp_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.APPNPConv, "modes": [MODES["SINGLE"], MODES["BATCH"], MODES["MIXED"]], "kwargs": {"channels": 8, "activation": "relu", "mlp_hidden": [16]}, "dense": True, "sparse": True, "edges": False, } def test_layer...
346
19.411765
72
py
spektral
spektral-master/tests/test_layers/convolutional/test_graphsage_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.GraphSageConv, "modes": [MODES["SINGLE"], MODES["MIXED"]], "kwargs": {"channels": 8, "activation": "relu"}, "dense": False, "sparse": True, "edges": False, } def test_layer(): run_layer(config)
315
17.588235
52
py
spektral
spektral-master/tests/test_layers/convolutional/test_diffusion_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.DiffusionConv, "modes": [MODES["SINGLE"], MODES["BATCH"], MODES["MIXED"]], "kwargs": {"channels": 8, "activation": "tanh", "num_diffusion_steps": 5}, "dense": True, "sparse": False, "edges": False, } def...
357
20.058824
78
py
spektral
spektral-master/tests/test_layers/convolutional/test_ecc_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.ECCConv, "modes": [MODES["SINGLE"], MODES["BATCH"], MODES["MIXED"]], "kwargs": {"kernel_network": [8], "channels": 8, "activation": "relu"}, "dense": True, "sparse": True, "edges": True, } def test_layer...
346
19.411765
75
py
spektral
spektral-master/tests/test_layers/convolutional/test_edge_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.EdgeConv, "modes": [MODES["SINGLE"], MODES["MIXED"]], "kwargs": {"channels": 8, "activation": "relu", "mlp_hidden": [16]}, "dense": False, "sparse": True, "edges": False, } def test_layer(): run_laye...
330
18.470588
72
py
spektral
spektral-master/tests/test_layers/convolutional/test_crystal_conv.py
from core import MODES, F, run_layer from spektral import layers config = { "layer": layers.CrystalConv, "modes": [MODES["SINGLE"], MODES["MIXED"]], "kwargs": {"channels": F}, # Set channels same as node features "dense": False, "sparse": True, "edges": True, } def test_layer(): run_lay...
331
18.529412
68
py
spektral
spektral-master/tests/test_layers/convolutional/test_gin_conv_batch.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.GINConvBatch, "modes": [MODES["BATCH"]], "kwargs": {"channels": 8, "activation": "relu", "mlp_hidden": [16]}, "dense": True, "sparse": True, "edges": False, } def test_layer(): run_layer(config) ...
376
18.842105
72
py
spektral
spektral-master/tests/test_layers/convolutional/test_gcn_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.GCNConv, "modes": [MODES["SINGLE"], MODES["BATCH"], MODES["MIXED"]], "kwargs": {"channels": 8, "activation": "relu"}, "dense": True, "sparse": True, "edges": False, } def test_layer(): run_layer(conf...
324
18.117647
63
py
spektral
spektral-master/tests/test_layers/convolutional/test_cheb_conv.py
from core import MODES, run_layer from spektral import layers config = { "layer": layers.ChebConv, "modes": [MODES["SINGLE"], MODES["BATCH"], MODES["MIXED"]], "kwargs": {"K": 3, "channels": 8, "activation": "relu"}, "dense": True, "sparse": True, "edges": False, } def test_layer(): run_l...
333
18.647059
63
py