Skip to content

Comments

Fix M4 dataset sequence length mismatch#813

Open
leviAckermea wants to merge 1 commit intothuml:mainfrom
leviAckermea:fix-m4-sequence-length
Open

Fix M4 dataset sequence length mismatch#813
leviAckermea wants to merge 1 commit intothuml:mainfrom
leviAckermea:fix-m4-sequence-length

Conversation

@leviAckermea
Copy link

问题描述

M4 数据集在加载时存在序列长度不一致的问题,导致readme训练与评测中第二个部分模型训练。
bash ./scripts/short_term_forecast/TimesNet_M4.sh
执行bug:

修改内容

  1. 调整 data_provider/m4.py 中数据解析逻辑,统一序列长度处理方式。
  2. 优化 {insert_element_0_YGRhdGFfcHJvdmlkZXIvZGF0YV9sb2FkZXIucHlg} 中的滑窗截取逻辑,兼容 M4 数据集的长度特性。

验证方式

已通过 {insert_element_1_YHNjcmlwdHMvc2hvcnRfdGVybV9mb3JlY2FzdC9UaW1lc05ldF9NNC5zaGA=} 脚本测试,可正常运行 M4 数据集的短期预测任务,无长度不匹配报错。

@leviAckermea
Copy link
Author

执行bug如下:ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (48000,) + inhomogeneous part.

@leehom0123-cmyk
Copy link

Epoch: 10 cost time: 143.77790188789368
Epoch: 10, Steps: 26 | Train Loss: 14.3322291 Vali Loss: 33.2273196 Test Loss: 33.2273196
EarlyStopping counter: 1 out of 3
Updating learning rate to 1.953125e-06

testing : short_term_forecast_m4_Hourly_TimesNet_m4_ftM_sl96_ll48_pl48_dm32_nh8_el2_dl1_df32_expand2_dc4_fc3_ebtimeF_dtTrue_Exp_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
train 414
test 414
0
test shape: (414, 48, 1)
TimesNet
Traceback (most recent call last):
File "/home/bit/tslib/run.py", line 224, in
exp.test(setting)
File "/home/bit/tslib/exp/exp_short_term_forecasting.py", line 228, in test
smape_results, owa_results, mape, mase = m4_summary.evaluate()
^^^^^^^^^^^^^^^^^^^^^
File "/home/bit/tslib/utils/m4_summary.py", line 67, in evaluate
naive2_forecasts = np.array([v[~np.isnan(v)] for v in naive2_forecasts])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (100000,) + inhomogeneous part.

我测试了一下,还有以上错误。

@leviAckermea
Copy link
Author

leviAckermea commented Jan 8, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants