magnet.aggmodels.sageheterogeneous.SageHeterogeneous#

class magnet.aggmodels.sageheterogeneous.SageHeterogeneous(hidden_units: int, lin_hidden_units: int, num_features: int, out_classes: int = 2)#

Bases: GNNHeterogeneous

GNN with 4 SAGE convolutional layers and 4 linear layers.

GNN for the agglomeration of heterogeneous meshes.

The convolutional layers have constant dimension of processed features, while the dense linear leayers have rpogressively decrasing dimension. The last dense layer is followed by a softmax layer.

Parameters:
  • hidden_units (int) – Number of hidden units of SAGEConv layers.

  • lin_hidden_units (int) – Number of linear hidden units.

  • num_features (int) – Number of input features

  • out_classes (int, optional) – Number of outputs (default is 2).

Variables:
  • conv4 (conv1, conv2, conv3,) – Convolutional SAGE layers.

  • lin_last (lin1, lin2, lin3,) – Linear layers.

  • act (torch.tanh) – Activation function.

Constructor

__init__(hidden_units: int, lin_hidden_units: int, num_features: int, out_classes: int = 2)#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Methods

__init__(hidden_units, lin_hidden_units, ...)

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x, edge_index)

Define the computation performed at every call.

__init__(hidden_units: int, lin_hidden_units: int, num_features: int, out_classes: int = 2)#

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, ...])

Returns a graph data structure sample for training.

load_model(model_path)

Load model from state dictionary.

loss_function(y, graph[, coeff])

Loss function used during training.

multilevel_bisection(mesh[, refiner, ...])

normalize(x, edge_index)

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.