def __init__(self, *graph, n_clusters=None, adj_transform="normalize_adj", attr_transform=None, device='cpu:0', seed=None, name=None, **kwargs): """Create a Cluster Graph Convolutional Networks (ClusterGCN) model. This can be instantiated in several ways: model = ClusterGCN(graph) with a `graphgallery.data.Graph` instance representing A sparse, attributed, labeled graph. model = ClusterGCN(adj_matrix, attr_matrix, labels) where `adj_matrix` is a 2D Scipy sparse matrix denoting the graph, `attr_matrix` is a 2D Numpy array-like matrix denoting the node attributes, `labels` is a 1D Numpy array denoting the node labels. Parameters: ---------- graph: An instance of `graphgallery.data.Graph` or a tuple (list) of inputs. A sparse, attributed, labeled graph. n_clusters: integer. optional The number of clusters that the graph being seperated, if not specified (`None`), it will be set to the number of classes automatically. (default :obj: `None`). adj_transform: string, `transform`, or None. optional How to transform the adjacency matrix. See `graphgallery.transforms` (default: :obj:`'normalize_adj'` with normalize rate `-0.5`. i.e., math:: \hat{A} = D^{-\frac{1}{2}} A D^{-\frac{1}{2}}) attr_transform: string, `transform`, or None. optional How to transform the node attribute matrix. See `graphgallery.transforms` (default :obj: `None`) device: string. optional The device where the model is running on. You can specified `CPU` or `GPU` for the model. (default: :str: `CPU:0`, i.e., running on the 0-th `CPU`) seed: interger scalar. optional Used in combination with `tf.random.set_seed` & `np.random.seed` & `random.seed` to create a reproducible sequence of tensors across multiple calls. (default :obj: `None`, i.e., using random seed) name: string. optional Specified name for the model. (default: :str: `class.__name__`) kwargs: other customized keyword Parameters. """ super().__init__(*graph, device=device, seed=seed, name=name, **kwargs) if not n_clusters: n_clusters = self.graph.n_classes self.n_clusters = n_clusters self.adj_transform = T.get(adj_transform) self.attr_transform = T.get(attr_transform) self.process()
def __init__(self, *graph, batch_size=256, rank=100, adj_transform="normalize_adj", attr_transform=None, device='cpu:0', seed=None, name=None, **kwargs): """Create a Fast Graph Convolutional Networks (FastGCN) model. This can be instantiated in several ways: model = FastGCN(graph) with a `graphgallery.data.Graph` instance representing A sparse, attributed, labeled graph. model = FastGCN(adj_matrix, attr_matrix, labels) where `adj_matrix` is a 2D Scipy sparse matrix denoting the graph, `attr_matrix` is a 2D Numpy array-like matrix denoting the node attributes, `labels` is a 1D Numpy array denoting the node labels. Parameters: ---------- graph: An instance of `graphgallery.data.Graph` or a tuple (list) of inputs. A sparse, attributed, labeled graph. batch_size (Positive integer, optional): Batch size for the training nodes. (default :int: `256`) rank (Positive integer, optional): The selected nodes for each batch nodes, `rank` must be smaller than `batch_size`. (default :int: `100`) adj_transform: string, `transform`, or None. optional How to transform the adjacency matrix. See `graphgallery.transforms` (default: :obj:`'normalize_adj'` with normalize rate `-0.5`. i.e., math:: \hat{A} = D^{-\frac{1}{2}} A D^{-\frac{1}{2}}) attr_transform: string, `transform`, or None. optional How to transform the node attribute matrix. See `graphgallery.transforms` (default :obj: `None`) device: string. optional The device where the model is running on. You can specified `CPU` or `GPU` for the model. (default: :str: `CPU:0`, i.e., running on the 0-th `CPU`) seed: interger scalar. optional Used in combination with `tf.random.set_seed` & `np.random.seed` & `random.seed` to create a reproducible sequence of tensors across multiple calls. (default :obj: `None`, i.e., using random seed) name: string. optional Specified name for the model. (default: :str: `class.__name__`) kwargs: other customized keyword Parameters. """ super().__init__(*graph, device=device, seed=seed, name=name, **kwargs) self.rank = rank self.batch_size = batch_size self.adj_transform = T.get(adj_transform) self.attr_transform = T.get(attr_transform) self.process()
def __init__(self, *graph, n_samples=(15, 5), adj_transform="neighbor_sampler", attr_transform=None, device='cpu:0', seed=None, name=None, **kwargs): """Create a SAmple and aggreGatE Graph Convolutional Networks (GraphSAGE) model. This can be instantiated in several ways: model = GraphSAGE(graph) with a `graphgallery.data.Graph` instance representing A sparse, attributed, labeled graph. model = GraphSAGE(adj_matrix, attr_matrix, labels) where `adj_matrix` is a 2D Scipy sparse matrix denoting the graph, `attr_matrix` is a 2D Numpy array-like matrix denoting the node attributes, `labels` is a 1D Numpy array denoting the node labels. Parameters: ---------- graph: An instance of `graphgallery.data.Graph` or a tuple (list) of inputs. A sparse, attributed, labeled graph. n_samples: List of positive integer. optional The number of sampled neighbors for each nodes in each layer. (default :obj: `(15, 5)`, i.e., sample `15` first-order neighbors and `5` sencond-order neighbors, and the radius for `GraphSAGE` is `2`) adj_transform: string, `transform`, or None. optional How to transform the adjacency matrix. See `graphgallery.transforms` (default: :obj:`'neighbor_sampler'`) attr_transform: string, `transform`, or None. optional How to transform the node attribute matrix. See `graphgallery.transforms` (default :obj: `None`) device: string. optional The device where the model is running on. You can specified `CPU` or `GPU` for the model. (default: :str: `CPU:0`, i.e., running on the 0-th `CPU`) seed: interger scalar. optional Used in combination with `tf.random.set_seed` & `np.random.seed` & `random.seed` to create a reproducible sequence of tensors across multiple calls. (default :obj: `None`, i.e., using random seed) name: string. optional Specified name for the model. (default: :str: `class.__name__`) kwargs: other customized keyword Parameters. """ super().__init__(*graph, device=device, seed=seed, name=name, **kwargs) self.n_samples = n_samples self.adj_transform = T.get(adj_transform) self.attr_transform = T.get(attr_transform) self.process()
def __init__(self, *graph, n_samples=50, adj_transform="normalize_adj", attr_transform=None, device='cpu:0', seed=None, name=None, **kwargs): """Create a sample-based Batch Virtual Adversarial Training Graph Convolutional Networks (SBVAT) model. This can be instantiated in several ways: model = SBVAT(graph) with a `graphgallery.data.Graph` instance representing A sparse, attributed, labeled graph. model = SBVAT(adj_matrix, attr_matrix, labels) where `adj_matrix` is a 2D Scipy sparse matrix denoting the graph, `attr_matrix` is a 2D Numpy array-like matrix denoting the node attributes, `labels` is a 1D Numpy array denoting the node labels. Parameters: ---------- graph: An instance of `graphgallery.data.Graph` or a tuple (list) of inputs. A sparse, attributed, labeled graph. n_samples (Positive integer, optional): The number of sampled subset nodes in the graph where the length of the shortest path between them is at least `4`. (default :obj: `50`) adj_transform: string, `transform`, or None. optional How to transform the adjacency matrix. See `graphgallery.transforms` (default: :obj:`'normalize_adj'` with normalize rate `-0.5`. i.e., math:: \hat{A} = D^{-\frac{1}{2}} A D^{-\frac{1}{2}}) attr_transform: string, `transform`, or None. optional How to transform the node attribute matrix. See `graphgallery.transforms` (default :obj: `None`) device: string. optional The device where the model is running on. You can specified `CPU` or `GPU` for the model. (default: :str: `CPU:0`, i.e., running on the 0-th `CPU`) seed: interger scalar. optional Used in combination with `tf.random.set_seed` & `np.random.seed` & `random.seed` to create a reproducible sequence of tensors across multiple calls. (default :obj: `None`, i.e., using random seed) name: string. optional Specified name for the model. (default: :str: `class.__name__`) kwargs: other customized keyword Parameters. """ super().__init__(*graph, device=device, seed=seed, name=name, **kwargs) self.adj_transform = T.get(adj_transform) self.attr_transform = T.get(attr_transform) self.n_samples = n_samples self.process()
def __init__(self, *graph, adj_transform="normalize_adj", attr_transform=None, device='cpu:0', seed=None, name=None, **kwargs): """Create a Edge Convolution version of Graph Convolutional Networks (EdgeGCN) model. This can be instantiated in several ways: model = EdgeGCN(graph) with a `graphgallery.data.Graph` instance representing A sparse, attributed, labeled graph. model = EdgeGCN(adj_matrix, attr_matrix, labels) where `adj_matrix` is a 2D Scipy sparse matrix denoting the graph, `attr_matrix` is a 2D Numpy array-like matrix denoting the node attributes, `labels` is a 1D Numpy array denoting the node labels. Parameters: ---------- graph: An instance of `graphgallery.data.Graph` or a tuple (list) of inputs. A sparse, attributed, labeled graph. adj_transform: string, `transform`, or None. optional How to transform the adjacency matrix. See `graphgallery.transforms` (default: :obj:`'normalize_adj'` with normalize rate `-0.5`. i.e., math:: \hat{A} = D^{-\frac{1}{2}} A D^{-\frac{1}{2}}) attr_transform: string, `transform`, or None. optional How to transform the node attribute matrix. See `graphgallery.transforms` (default :obj: `None`) device: string. optional The device where the model is running on. You can specified `CPU` or `GPU` for the model. (default: :str: `CPU:0`, i.e., running on the 0-th `CPU`) seed: interger scalar. optional Used in combination with `tf.random.set_seed` & `np.random.seed` & `random.seed` to create a reproducible sequence of tensors across multiple calls. (default :obj: `None`, i.e., using random seed) name: string. optional Specified name for the model. (default: :str: `class.__name__`) kwargs: other customized keyword Parameters. Note: ---------- The Graph Edge Convolutional implements the operation using message passing framework, i.e., using Tensor `edge index` and `edge weight` of adjacency matrix to aggregate neighbors' message, instead of SparseTensor `adj`. """ super().__init__(*graph, device=device, seed=seed, name=name, **kwargs) self.adj_transform = T.get(adj_transform) self.attr_transform = T.get(attr_transform) self.process()
def __init__(self, *graph, adj_transform="wavelet_basis", attr_transform=None, device='cpu:0', seed=None, name=None, **kwargs): """Create a Graph Wavelet Neural Networks (GWNN) model. This can be instantiated in several ways: model = GWNN(graph) with a `graphgallery.data.Graph` instance representing A sparse, attributed, labeled graph. model = GWNN(adj_matrix, attr_matrix, labels) where `adj_matrix` is a 2D Scipy sparse matrix denoting the graph, `attr_matrix` is a 2D Numpy array-like matrix denoting the node attributes, `labels` is a 1D Numpy array denoting the node labels. Parameters: ---------- graph: An instance of `graphgallery.data.Graph` or a tuple (list) of inputs. A sparse, attributed, labeled graph. adj_transform: string, `transform`, or None. optional How to transform the adjacency matrix. See `graphgallery.transforms` (default: :obj:`'wavelet_basis'`.) attr_transform: string, `transform`, or None. optional How to transform the node attribute matrix. See `graphgallery.transforms` (default :obj: `None`) device: string. optional The device where the model is running on. You can specified `CPU` or `GPU` for the model. (default: :str: `CPU:0`, i.e., running on the 0-th `CPU`) seed: interger scalar. optional Used in combination with `tf.random.set_seed` & `np.random.seed` & `random.seed` to create a reproducible sequence of tensors across multiple calls. (default :obj: `None`, i.e., using random seed) name: string. optional Specified name for the model. (default: :str: `class.__name__`) kwargs: other customized keyword Parameters. """ super().__init__(*graph, device=device, seed=seed, name=name, **kwargs) self.adj_transform = T.get(adj_transform) self.attr_transform = T.get(attr_transform) self.process()