diff --git a/pytorch_forecasting/metrics.py b/pytorch_forecasting/metrics.py index 72ac211e..a0799503 100644 --- a/pytorch_forecasting/metrics.py +++ b/pytorch_forecasting/metrics.py @@ -1103,10 +1103,14 @@ def to_quantiles(self, y_pred: torch.Tensor, quantiles: List[float] = None, n_sa quantiles = self.quantiles try: distribution = self.map_x_to_distribution(y_pred) - quantiles = distribution.icdf(torch.tensor(quantiles, device=y_pred.device)[:, None, None]).permute(1, 2, 0) + quantiles = distribution.icdf( + torch.tensor(quantiles, device=y_pred.device, dtype=torch.float64)[:, None, None] + ).permute(1, 2, 0) except NotImplementedError: # resort to derive quantiles empirically samples = torch.sort(self.sample(y_pred, n_samples), -1).values - quantiles = torch.quantile(samples, torch.tensor(quantiles, device=samples.device), dim=2).permute(1, 2, 0) + quantiles = torch.quantile( + samples, torch.tensor(quantiles, device=samples.device, dtype=torch.float64), dim=2 + ).permute(1, 2, 0) return quantiles diff --git a/pytorch_forecasting/models/deepar/__init__.py b/pytorch_forecasting/models/deepar/__init__.py index 285a9a8d..5123f1f5 100644 --- a/pytorch_forecasting/models/deepar/__init__.py +++ b/pytorch_forecasting/models/deepar/__init__.py @@ -280,7 +280,7 @@ def decode_one( hidden_state, ): x = input_vector[:, [idx]] - x[:, 0, target_pos] = lagged_targets[-1] + x[:, 0, target_pos] = lagged_targets[-1].float() for lag, lag_positions in lagged_target_positions.items(): if idx > lag: x[:, 0, lag_positions] = lagged_targets[-lag]