dynabench.model.utils

Classes

CloudRolloutWrapper(model[, batch_first, ...])

Alias for dynabench.model.utils.RolloutWrapper with structure="cloud"

GridRolloutWrapper(model[, batch_first, ...])

Alias for dynabench.model.utils.RolloutWrapper with structure="grid"

RolloutWrapper(model[, structure, ...])

Wrapper class for iterative model evaluation.

class dynabench.model.utils.CloudRolloutWrapper(model, batch_first: bool = True, lookback_dim: int = 1, is_lookback_squeezed: bool = False)[source]

Bases: RolloutWrapper

Alias for dynabench.model.utils.RolloutWrapper with structure=”cloud”

class dynabench.model.utils.GridRolloutWrapper(model, batch_first: bool = True, lookback_dim: int = 1, is_lookback_squeezed: bool = False)[source]

Bases: RolloutWrapper

Alias for dynabench.model.utils.RolloutWrapper with structure=”grid”

class dynabench.model.utils.RolloutWrapper(model, structure: str = 'grid', batch_first: bool = True, lookback_dim: int = 1, is_lookback_squeezed: bool = False)[source]

Bases: Module

Wrapper class for iterative model evaluation. This class is designed to perform iterative evaluation of models by calling the model multiple times at different time points. It can be used for both point-based and grid-based models.

Parameters:
  • model (torch.nn.Module) – The model to be wrapped and iteratively evaluated.

  • batch_first (bool, default True) – If True, the first dimension of the input tensor is considered as the batch dimension. If False, the first dimension is the rollout dimension.

  • feature_dim (int, default -1) – The id of the feature dimension.

  • lookback_dim (int, default 1) – The id of the lookback dimension.

  • structure (str, default 'grid') – The structure of the input data. Can be either ‘grid’ or ‘cloud’.

  • is_lookback_squeezed (bool, default False) – If True, the lookback dimension is squeezed. If True, the lookback dimension parameter is ignored.

forward(x: Tensor, p: Tensor | None = None, t_eval: List[float] = [1])[source]

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.