From 9287e0b62b04e204e5a6318f9e89bcd4f8b9c5d0 Mon Sep 17 00:00:00 2001 From: binbin Deng <108676127+plusbang@users.noreply.github.com> Date: Tue, 23 Aug 2022 13:23:49 +0800 Subject: [PATCH] Chronos: an error message is added to AutoformerForecaster.predict() (#5483) When the input data to AutoformerForecaster.predict() is incorrect, the error message is confusing. Thus, a new error message is added. --- .../src/bigdl/chronos/forecaster/autoformer_forecaster.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/chronos/src/bigdl/chronos/forecaster/autoformer_forecaster.py b/python/chronos/src/bigdl/chronos/forecaster/autoformer_forecaster.py index fb09b814271..427c0741abb 100644 --- a/python/chronos/src/bigdl/chronos/forecaster/autoformer_forecaster.py +++ b/python/chronos/src/bigdl/chronos/forecaster/autoformer_forecaster.py @@ -368,6 +368,9 @@ def predict(self, data, batch_size=32): """ if self.distributed: invalidInputError(False, "distributed is not support in Autoformer") + invalidInputError(isinstance(data, tuple) or isinstance(data, DataLoader), + "The input data to predict() support formats: numpy ndarray tuple" + f" and pytorch dataloader, but found {type(data)}.") if isinstance(data, tuple): data = DataLoader(TensorDataset(torch.from_numpy(data[0]), torch.from_numpy(data[1]),