|
18 | 18 | from pytorch_forecasting.metrics import ( |
19 | 19 | MAE, |
20 | 20 | MAPE, |
21 | | - MASE, |
22 | 21 | RMSE, |
23 | 22 | SMAPE, |
24 | 23 | MultiHorizonMetric, |
25 | | - QuantileLoss, |
26 | 24 | ) |
27 | 25 | from pytorch_forecasting.metrics.base_metrics import MultiLoss |
28 | 26 | from pytorch_forecasting.models.base import BaseModelWithCovariates |
@@ -222,16 +220,6 @@ def __init__( |
222 | 220 | if enc_in is None: |
223 | 221 | self.enc_in = len(self.reals) |
224 | 222 |
|
225 | | - # NOTE: assume point prediction as default here, |
226 | | - # with single median quantile being the point prediction. |
227 | | - # hence self.n_quantiles = 1 for point predictions. |
228 | | - self.n_quantiles = 1 |
229 | | - |
230 | | - # set n_quantiles to the length of the quantiles list passed |
231 | | - # into the "quantiles" parameter when QuantileLoss is used. |
232 | | - if isinstance(loss, QuantileLoss): |
233 | | - self.n_quantiles = len(loss.quantiles) |
234 | | - |
235 | 223 | if hidden_size % n_heads != 0: |
236 | 224 | raise ValueError( |
237 | 225 | f"hidden_size ({hidden_size}) must be divisible by n_heads ({n_heads}) " |
@@ -302,7 +290,6 @@ def __init__( |
302 | 290 | self.head_nf, |
303 | 291 | self.hparams.prediction_length, |
304 | 292 | head_dropout=self.hparams.dropout, |
305 | | - n_quantiles=self.n_quantiles, |
306 | 293 | ) |
307 | 294 |
|
308 | 295 | @classmethod |
@@ -507,11 +494,7 @@ def forward(self, x: dict[str, torch.Tensor]) -> dict[str, torch.Tensor]: |
507 | 494 | if prediction.size(2) != len(target_positions): |
508 | 495 | prediction = prediction[:, :, : len(target_positions)] |
509 | 496 |
|
510 | | - # output format is (batch_size, prediction_length, n_quantiles) |
511 | | - # in case of quantile loss, the output n_quantiles = self.n_quantiles |
512 | | - # which is the length of a list of float. In case of MAE, MSE, etc. |
513 | | - # n_quantiles = 1 and it mimics the behavior of a point prediction. |
514 | | - # for multi-target forecasting, the output is a list of tensors. |
| 497 | + # output format is (batch_size, prediction_length, n_targets) |
515 | 498 | if len(target_positions) == 1: |
516 | 499 | prediction = prediction[..., 0, :] |
517 | 500 | else: |
|
0 commit comments