tsicl.utils.utils.complete_nans#

tsicl.utils.utils.complete_nans(X: torch.Tensor, grid: torch.Tensor, is_test: bool = False, X_cov: torch.Tensor | None = None) Dict[str, torch.Tensor]#

Fills missing values (NaNs) in a target tensor (replaced by observed values at random instants of the same series).

Parameters:
  • X (torch.Tensor) – value tensor of shape (bs, seq_len, 1).

  • grid (torch.Tensor) – grid coord tensor of shape (bs, seq_len, 1).

  • is_test (bool) – True if test mode.

  • X_cov (torch.Tensor | None) – optional tensor of covariates of shape (bs, c, seq_len, 1). Will not remove all NaNs from X_cov, only make sure it remains aligned with X.

Returns:

Dict storing ‘values’ and ‘coords’ tensors of shape (bs, seq_len, 1) with duplicates instead of NaNs. Also contains ‘covar’ tensor if X_cov was supplied.