dynabench.model.utils

Classes

GridIterativeWrapper(model[, batch_first])

Wrapper class for iterative grid-based model evaluation.

PointIterativeWrapper(model[, batch_first])

Wrapper class for iterative point-based model evaluation.

class dynabench.model.utils.GridIterativeWrapper(model, batch_first: bool = True)[source]

Bases: Module

Wrapper class for iterative grid-based model evaluation.

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.

model

The wrapped model.

Type:

torch.nn.Module

batch_first

Indicates if the first dimension of the input tensor is the batch dimension.

Type:

bool

forward(x: torch.Tensor, t_eval: List[float] = [1]) torch.Tensor[source]

Perform iterative evaluation of the model at specified time points.

forward(x: Tensor, 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.

class dynabench.model.utils.PointIterativeWrapper(model, batch_first: bool = True)[source]

Bases: Module

Wrapper class for iterative point-based model evaluation.

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.

model

The wrapped model.

Type:

torch.nn.Module

batch_first

Indicates if the first dimension of the input tensor is the batch dimension.

Type:

bool

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

Perform iterative evaluation of the model at specified time points.

forward(x: Tensor, p: Tensor, 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.