easy_model¶
Suggested Model subclass that enables simple user syntax.
- class graphnet.models.easy_model.EasySyntax(*args, **kwargs)[source]¶
Bases:
Model
A suggested Model class that comes with simple user syntax.
This class delivers simple user syntax for training and prediction, while imposing minimal constraints on structure.
Construct StandardModel.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
object
- compute_loss(preds, data, verbose)[source]¶
Compute and sum losses across tasks.
- Return type:
Tensor
- Parameters:
preds (Tensor)
data (List[Data])
verbose (bool)
- forward(data)[source]¶
Forward pass, chaining model components.
- Return type:
List
[Union
[Tensor
,Data
]]- Parameters:
data (Data | List[Data])
Perform shared step.
Applies the forward pass and the following loss calculation, shared between the training and validation step.
- Return type:
Tensor
- Parameters:
batch (List[Data])
batch_idx (int)
- fit(train_dataloader, val_dataloader, *, max_epochs, early_stopping_patience, gpus, callbacks, ckpt_path, logger, log_every_n_steps, gradient_clip_val, distribution_strategy, **trainer_kwargs)[source]¶
Fit StandardModel using pytorch_lightning.Trainer.
- Return type:
None
- Parameters:
train_dataloader (DataLoader)
val_dataloader (DataLoader | None)
max_epochs (int)
early_stopping_patience (int)
gpus (List[int] | int | None)
callbacks (List[Callback] | None)
ckpt_path (str | None)
logger (Logger | None)
log_every_n_steps (int)
gradient_clip_val (float | None)
distribution_strategy (str | None)
trainer_kwargs (Any)
- property target_labels: List[str]¶
Return target label.
- property prediction_labels: List[str]¶
Return prediction labels.
- training_step(train_batch, batch_idx)[source]¶
Perform training step.
- Return type:
Tensor
- Parameters:
train_batch (Data | List[Data])
batch_idx (int)
- validation_step(val_batch, batch_idx)[source]¶
Perform validation step.
- Return type:
Tensor
- Parameters:
val_batch (Data | List[Data])
batch_idx (int)
- predict(dataloader, gpus, distribution_strategy, **trainer_kwargs)[source]¶
Return predictions for dataloader.
- Return type:
List
[Tensor
]- Parameters:
dataloader (DataLoader)
gpus (List[int] | int | None)
distribution_strategy (str | None)
trainer_kwargs (Any)
- predict_as_dataframe(dataloader, prediction_columns, *, additional_attributes, gpus, distribution_strategy, **trainer_kwargs)[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)
trainer_kwargs (Any)