standard_model

Standard model class(es).

class graphnet.models.standard_model.StandardModel(*args, **kwargs)[source]

Bases: Model

Main class for standard models in graphnet.

This class chains together the different elements of a complete GNN-based model (detector read-in, GNN architecture, and task-specific read-outs).

Construct StandardModel.

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

object

property target_labels: List[str]

Return target label.

property prediction_labels: List[str]

Return prediction labels.

configure_optimizers()[source]

Configure the model’s optimizer(s).

Return type:

Dict[str, Any]

forward(data)[source]

Forward pass, chaining model components.

Return type:

List[Union[Tensor, Data]]

Parameters:

data (Data) –

shared_step(batch, batch_idx)[source]

Perform shared step.

Applies the forward pass and the following loss calculation, shared between the training and validation step.

Return type:

Tensor

Parameters:
  • batch (Data) –

  • batch_idx (int) –

training_step(train_batch, batch_idx)[source]

Perform training step.

Return type:

Tensor

Parameters:
  • train_batch (Data) –

  • batch_idx (int) –

validation_step(val_batch, batch_idx)[source]

Perform validation step.

Return type:

Tensor

Parameters:
  • val_batch (Data) –

  • batch_idx (int) –

compute_loss(preds, data, verbose)[source]

Compute and sum losses across tasks.

Return type:

Tensor

Parameters:
  • preds (Tensor) –

  • data (Data) –

  • verbose (bool) –

inference()[source]

Activate inference mode.

Return type:

None

train(mode)[source]

Deactivate inference mode.

Return type:

Model

Parameters:

mode (bool) –

predict(dataloader, gpus, distribution_strategy)[source]

Return predictions for dataloader.

Return type:

List[Tensor]

Parameters:
  • dataloader (DataLoader) –

  • gpus (List[int] | int | None) –

  • distribution_strategy (str | None) –

predict_as_dataframe(dataloader, prediction_columns, *, additional_attributes, gpus, distribution_strategy)[source]

Return predictions for dataloader as a DataFrame.

Include additional_attributes as additional columns in the output DataFrame.

Return type:

DataFrame

Parameters:
  • dataloader (DataLoader) –

  • prediction_columns (List[str] | None) –

  • additional_attributes (List[str] | None) –

  • gpus (List[int] | int | None) –

  • distribution_strategy (str | None) –