Closed IgnoranceSmile closed 5 months ago
您好,我们跟进复现下您的问题。
您好,这个是因为损失函数使用了默认的3维度的quantiles。如果希望使用2维度,可以修改这行代码的quantiles。这个问题我们也会排期修复。https://github.com/PaddlePaddle/PaddleTS/blob/a3f275c51a1c6d6803ec2af269c049a29039ae59/paddlets/models/forecasting/dl/distributions/likelihood.py#L167
是否output_quantiles只支持长度为1和3,测试在其他长度下均会报错。
示例代码: import pandas as pd import numpy as np from paddlets import TSDataset
x = np.linspace(-np.pi, np.pi, 200) sinx = np.sin(x) * 4 + np.random.randn(200)
df = pd.DataFrame( { 'time_col': pd.date_range('2022-01-01', periods=200, freq='1h'), 'value': sinx } ) target_dataset = TSDataset.load_from_dataframe( df, #Also can be path to the CSV file time_col='time_col', target_cols='value', freq='1h' ) new_line = pd.Series( np.array(range(210)), index=pd.date_range('2022-01-01', periods=210, freq='1h') ) target_dataset.set_column( column='new_b', value=new_line, type='known_cov' ) train_ts, val_ts = target_dataset.split(0.7)
from paddlets.models.forecasting import TransformerModel, TFTModel, RNNBlockRegressor
model = TFTModel( in_chunk_len = 10, out_chunk_len = 10, output_quantiles = [0.1, 0.2] ) model.fit(train_ts)
报错:
ValueError Traceback (most recent call last) /tmp/ipykernel_20005/1436158038.py in
6 output_quantiles = [0.1, 0.2]
7 )
----> 8 model.fit(train_ts)
/usr/local/lib/python3.7/dist-packages/paddlets/models/forecasting/dl/paddle_base_impl.py in fit(self, train_tsdataset, valid_tsdataset) 344 self._check_multi_tsdataset(valid_tsdataset) 345 train_dataloader, valid_dataloaders = self._init_fit_dataloaders(train_tsdataset, valid_tsdataset) --> 346 self._fit(train_dataloader, valid_dataloaders) 347 348 def _fit(
/usr/local/lib/python3.7/dist-packages/paddlets/models/forecasting/dl/paddle_base_impl.py in _fit(self, train_dataloader, valid_dataloaders) 370 # Call the
on_epoch_begin
method of each callback before the epoch starts. 371 self._callback_container.on_epoch_begin(epoch_idx) --> 372 self._train_epoch(train_dataloader) 373 374 # Predict for each eval set./usr/local/lib/python3.7/dist-packages/paddlets/models/forecasting/dl/paddle_base_impl.py in _train_epoch(self, train_loader) 438 self._callback_container.on_batch_begin(batch_idx) 439 X, y = self._prepare_X_y(data) --> 440 batch_logs = self._train_batch(X, y) ... 301 comment = OpProtoHolder.instance().get_op_proto(op_type).comment
ValueError: (InvalidArgument) Broadcast dimension mismatch. Operands could not be broadcast together with the shape of X = [3] and the shape of Y = [121, 10, 1, 2]. Received [3] in X is not equal to [2] in Y at i:3. [Hint: Expected x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1 == true, but received x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1:0 != true:1.] (at /paddle/paddle/phi/kernels/funcs/common_shape.h:84) [operator < elementwise_mul > error]