From e7dadbe72b2a708457caadd23c5291346de5ac3b Mon Sep 17 00:00:00 2001 From: Julian Minder Date: Mon, 6 Mar 2023 12:24:01 +0100 Subject: [PATCH 1/3] The graphgps data loader no longer overshadows all other dataloaders. This allows users of the library to add their own datasets --- graphgps/loader/master_loader.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/graphgps/loader/master_loader.py b/graphgps/loader/master_loader.py index edadb7e8..a53b9d28 100644 --- a/graphgps/loader/master_loader.py +++ b/graphgps/loader/master_loader.py @@ -82,10 +82,8 @@ def log_loaded_dataset(dataset, format, name): @register_loader('custom_master_loader') def load_dataset_master(format, name, dataset_dir): """ - Master loader that controls loading of all datasets, overshadowing execution - of any default GraphGym dataset loader. Default GraphGym dataset loader are - instead called from this function, the format keywords `PyG` and `OGB` are - reserved for these default GraphGym loaders. + Master loader that controls loading of all GraphGPS datasets, overshadowing execution + of 'OGB' datasets. Custom transforms and dataset splitting is applied to each loaded dataset. @@ -143,11 +141,6 @@ def load_dataset_master(format, name, dataset_dir): else: raise ValueError(f"Unexpected PyG Dataset identifier: {format}") - - # GraphGym default loader for Pytorch Geometric datasets - elif format == 'PyG': - dataset = load_pyg(name, dataset_dir) - elif format == 'OGB': if name.startswith('ogbg'): dataset = preformat_OGB_Graph(dataset_dir, name.replace('_', '-')) @@ -178,7 +171,7 @@ def convert_to_int(ds, prop): else: raise ValueError(f"Unsupported OGB(-derived) dataset: {name}") else: - raise ValueError(f"Unknown data format: {format}") + return None # Not a custom graphgps dataset. Fall back to other loaders pre_transform_in_memory(dataset, partial(task_specific_preprocessing, cfg=cfg)) From 34dd9a7c0258d5f1a21ee8a9633acb9503de3f04 Mon Sep 17 00:00:00 2001 From: Julian Minder Date: Mon, 6 Mar 2023 19:47:12 +0100 Subject: [PATCH 2/3] gatedgcn layer now also supports graphs with no edge attributes --- graphgps/layer/gatedgcn_layer.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/graphgps/layer/gatedgcn_layer.py b/graphgps/layer/gatedgcn_layer.py index 998e5ea1..886325ef 100644 --- a/graphgps/layer/gatedgcn_layer.py +++ b/graphgps/layer/gatedgcn_layer.py @@ -56,7 +56,8 @@ def forward(self, batch): Ax = self.A(x) Bx = self.B(x) - Ce = self.C(e) + if e is not None: + Ce = self.C(e) Dx = self.D(x) Ex = self.E(x) @@ -69,31 +70,35 @@ def forward(self, batch): e=e, Ax=Ax, PE=pe_LapPE) - x = self.bn_node_x(x) - e = self.bn_edge_e(e) + + if e is not None: + e = self.bn_edge_e(e) + e = self.act_fn_e(e) + e = F.dropout(e, self.dropout, training=self.training) + x = self.bn_node_x(x) x = self.act_fn_x(x) - e = self.act_fn_e(e) - x = F.dropout(x, self.dropout, training=self.training) - e = F.dropout(e, self.dropout, training=self.training) if self.residual: x = x_in + x - e = e_in + e + if e is not None: + e = e_in + e batch.x = x batch.edge_attr = e return batch - def message(self, Dx_i, Ex_j, PE_i, PE_j, Ce): + def message(self, Dx_i, Ex_j, PE_i, PE_j, Ce=None): """ {}x_i : [n_edges, out_dim] {}x_j : [n_edges, out_dim] {}e : [n_edges, out_dim] """ - e_ij = Dx_i + Ex_j + Ce + e_ij = Dx_i + Ex_j + if Ce is not None: + e_ij = e_ij + Ce sigma_ij = torch.sigmoid(e_ij) # Handling for Equivariant and Stable PE using LapPE From 3a0be3e96d8d5b9af3d466304e396f4d779d890d Mon Sep 17 00:00:00 2001 From: Julian Minder Date: Fri, 10 Mar 2023 21:29:51 +0100 Subject: [PATCH 3/3] Revert "gatedgcn layer now also supports graphs with no edge attributes" This reverts commit 34dd9a7c0258d5f1a21ee8a9633acb9503de3f04. Was wrongly commited to the main branch. --- graphgps/layer/gatedgcn_layer.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/graphgps/layer/gatedgcn_layer.py b/graphgps/layer/gatedgcn_layer.py index 886325ef..998e5ea1 100644 --- a/graphgps/layer/gatedgcn_layer.py +++ b/graphgps/layer/gatedgcn_layer.py @@ -56,8 +56,7 @@ def forward(self, batch): Ax = self.A(x) Bx = self.B(x) - if e is not None: - Ce = self.C(e) + Ce = self.C(e) Dx = self.D(x) Ex = self.E(x) @@ -70,35 +69,31 @@ def forward(self, batch): e=e, Ax=Ax, PE=pe_LapPE) - - if e is not None: - e = self.bn_edge_e(e) - e = self.act_fn_e(e) - e = F.dropout(e, self.dropout, training=self.training) - x = self.bn_node_x(x) + e = self.bn_edge_e(e) + x = self.act_fn_x(x) + e = self.act_fn_e(e) + x = F.dropout(x, self.dropout, training=self.training) + e = F.dropout(e, self.dropout, training=self.training) if self.residual: x = x_in + x - if e is not None: - e = e_in + e + e = e_in + e batch.x = x batch.edge_attr = e return batch - def message(self, Dx_i, Ex_j, PE_i, PE_j, Ce=None): + def message(self, Dx_i, Ex_j, PE_i, PE_j, Ce): """ {}x_i : [n_edges, out_dim] {}x_j : [n_edges, out_dim] {}e : [n_edges, out_dim] """ - e_ij = Dx_i + Ex_j - if Ce is not None: - e_ij = e_ij + Ce + e_ij = Dx_i + Ex_j + Ce sigma_ij = torch.sigmoid(e_ij) # Handling for Equivariant and Stable PE using LapPE