classification

Classification-specific Model class(es).

class graphnet.models.task.classification.MulticlassClassificationTask(*args, **kwargs)[source]

Bases: IdentityTask

General task for classifying any number of classes.

Requires the same number of input features as the number of classes being predicted. Returns the untransformed latent features, which are interpreted as the logits for each class being classified.

Construct IdentityTask.

Return the nb_outputs as a direct, affine transformation of the last hidden layer.

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

object

class graphnet.models.task.classification.BinaryClassificationTask(*args, **kwargs)[source]

Bases: Task

Performs binary classification.

Construct Task.

Parameters:
  • hidden_size (int) – The number of nodes in the layer feeding into this tasks, used to construct the affine transformation to the predicted quantity.

  • loss_function (LossFunction) – Loss function appropriate to the task.

  • target_labels (Union[str, List[str], None], default: None) – Name(s) of the quantity/-ies being predicted, used to extract the target tensor(s) from the Data object in .compute_loss(…).

  • prediction_labels (Union[str, List[str], None], default: None) – The name(s) of each column that is predicted by the model during inference. If not given, the name will auto matically be set to target_label + _pred.

  • transform_prediction_and_target (Optional[Callable], default: None) – Optional function to transform both the predicted and target tensor before passing them to the loss function. Useful e.g. for having the model predict quantities on a physical scale, but transforming this scale to O(1) for a numerically stable loss computation.

  • transform_target (Optional[Callable], default: None) – Optional function to transform only the target tensor before passing it, and the predicted tensor, to the loss function. Useful e.g. for having the model predict a transformed version of the target quantity, e.g. the log10- scaled energy, rather than the physical quantity itself. Used in conjunction with transform_inference to perform the inverse transform on the predicted quantity to recover the physical scale.

  • transform_inference (Optional[Callable], default: None) – Optional function to inverse-transform the model prediction to recover a physical scale. Used in conjunction with transform_target.

  • transform_support (Optional[Tuple], default: None) – Optional tuple to specify minimum and maximum of the range of validity for the inverse transforms transform_target and transform_inference in case this is restricted. By default the invertibility of transform_target is tested on the range [-1e6, 1e6].

  • loss_weight (Optional[str], default: None) – Name of the attribute in data containing per-event loss weights.

  • args (Any) –

  • kwargs (Any) –

Return type:

object

nb_inputs = 1
default_target_labels = ['target']
default_prediction_labels = ['target_pred']
class graphnet.models.task.classification.BinaryClassificationTaskLogits(*args, **kwargs)[source]

Bases: Task

Performs binary classification form logits.

Construct Task.

Parameters:
  • hidden_size (int) – The number of nodes in the layer feeding into this tasks, used to construct the affine transformation to the predicted quantity.

  • loss_function (LossFunction) – Loss function appropriate to the task.

  • target_labels (Union[str, List[str], None], default: None) – Name(s) of the quantity/-ies being predicted, used to extract the target tensor(s) from the Data object in .compute_loss(…).

  • prediction_labels (Union[str, List[str], None], default: None) – The name(s) of each column that is predicted by the model during inference. If not given, the name will auto matically be set to target_label + _pred.

  • transform_prediction_and_target (Optional[Callable], default: None) – Optional function to transform both the predicted and target tensor before passing them to the loss function. Useful e.g. for having the model predict quantities on a physical scale, but transforming this scale to O(1) for a numerically stable loss computation.

  • transform_target (Optional[Callable], default: None) – Optional function to transform only the target tensor before passing it, and the predicted tensor, to the loss function. Useful e.g. for having the model predict a transformed version of the target quantity, e.g. the log10- scaled energy, rather than the physical quantity itself. Used in conjunction with transform_inference to perform the inverse transform on the predicted quantity to recover the physical scale.

  • transform_inference (Optional[Callable], default: None) – Optional function to inverse-transform the model prediction to recover a physical scale. Used in conjunction with transform_target.

  • transform_support (Optional[Tuple], default: None) – Optional tuple to specify minimum and maximum of the range of validity for the inverse transforms transform_target and transform_inference in case this is restricted. By default the invertibility of transform_target is tested on the range [-1e6, 1e6].

  • loss_weight (Optional[str], default: None) – Name of the attribute in data containing per-event loss weights.

  • args (Any) –

  • kwargs (Any) –

Return type:

object

nb_inputs = 1
default_target_labels = ['target']
default_prediction_labels = ['target_pred']