magnet.aggmodels.sagebase.SageRes#
- class magnet.aggmodels.sagebase.SageRes#
Bases:
GeometricGNN
GNN that uses residual connections.
This GNN is formed by 7 SAGEConv layers: the first 4 have an increasing depth of the hidden representation, while the last 3 have decresing depth. The convolutional layers are followed by 3 dense linear layers and a softmax layer.
- Variables:
conv3r (conv1, conv2, conv3, conv4, conv1r, conv2r,) – Convolutional SAGE layers.
lin_last (lin1, lin2,) – Dense linear layers.
act (torch.tanh) – Activation function.
Constructor
- __init__()#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
Methods
__init__
()Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward
(x, edge_index)Define the computation performed at every call.
- __init__()#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, edge_index)#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
Inherited Methods
agglomerate
(mesh[, mode, nref, mult_factor])Agglomerate a mesh.
agglomerate_dataset
(dataset, **kwargs)Agglomerate all meshes in a dataset.
bisect
(mesh)Bisect the mesh once.
bisection_Nref
(mesh, Nref[, warm_start])Bisect the mesh recursively a set number of times.
bisection_mult_factor
(mesh, mult_factor[, ...])Bisect a mesh until the agglomerated elements are small enough.
bisection_segregated
(mesh, mult_factor[, subset])Bisect heterogeneous mesh until elements are small enough.
coarsen
(mesh, subset[, mode, nref, mult_factor])Coarsen a subregion of the mesh.
get_number_of_parameters
()Get total number of parameters of the GNN.
get_sample
(mesh[, randomRotate, selfloop, ...])create a graph data structure sample from a mesh.
load_model
(model_path)Load model from state dictionary.
loss_function
(output, graph)Loss function used during training.
multilevel_bisection
(mesh[, refiner, ...])normalize
(x)Normalize the data before feeding it to the GNN.
save_model
(output_path)Save current model to state dictionary.
train_GNN
(training_dataset, ...[, ...])Train the Graph Neural Network.
Note
This class inherits from
torch.nn.Module
. To see the full list of inherited members, please see the Pytorch documentation.