Skip to content

05-收束

本文件作用

本文件把 TimesNet 文档集收束成一张可复习的完整接口树。它不新增复杂细节,只负责把入口、主链、子块、出口接起来。

1. 完整执行树

2. 文件对应关系

文件层级入口出口
[[00-总览]]总览TimesNet 文档集学习路径与全局图
[[调试形参]]调试入口run_benchmark.py 参数可直接复制到 PyCharm / VSCode 的参数
[[01-Layer0-接入界面]]Layer0forecast_fit() 补齐 config + TransformerAdapter._process()TimesNet.forward(x_enc, x_mark_enc, x_dec, x_mark_dec)
[[02-Layer1-forecast主链]]Layer1TimesNet.forecast(x_enc, x_mark_enc, x_dec, x_mark_dec)dec_out: (B,seq_len+pred_len,c_out)
[[03A-Layer2A-DataEmbedding]]Layer2Aself.enc_embedding(x_enc, x_mark_enc)enc_out: (B,seq_len,d_model)
[[03B-Layer2B-TimesBlock]]Layer2Bself.model[i](enc_out)enc_out: (B,T,d_model)
[[03B1-Layer3-FFT_for_Period]]Layer3FFT_for_Period(x,k)period_listperiod_weight
[[03B2-Layer3-Inception_Block_V1]]Layer3self.conv(out)二维周期网格卷积输出

3. 一句话掌握 TimesNet

TimesNet 的主线是:

text
归一化数值序列
-> 嵌入到 hidden 空间
-> 用线性层把时间长度扩展到历史+未来
-> FFT 找主要周期
-> 每个周期把 1D 时间折成 2D 周期网格
-> 用多尺度 2D 卷积提取周期模式
-> 按周期强度加权融合
-> 映射回原变量空间
-> 反归一化并截取未来窗口

4. toy shape 总表

步骤张量
x_enc(3,8,4)
_process 构造 x_dec(3,9,4)
Normalization(3,8,4)
DataEmbedding(3,8,6)
permute(0,2,1)(3,6,8)
predict_linear: 8 -> 13(3,6,13)
permute(0,2,1)(3,13,6)
TimesBlock 输入(3,13,6)
period=4 padding(3,16,6)
period=4 2D grid(3,6,4,4)
Inception conv(3,6,4,4)
reshape back and crop(3,13,6)
stack top_k=2(3,13,6,2)
weighted sum + residual(3,13,6)
projection(3,13,4)
De-Normalization(3,13,4)
forward tail slice(3,5,4)

5. 与已学模型的差异

模型核心操作代码阅读重点
DLinear趋势/季节分解 + 线性层分解窗口、Linear 输入输出
PatchTSTpatch 化 + Transformer Encoderunfold、patch embedding、attention
InformerProbSparse Attention + Encoder/DecoderQ/K/V、ProbAttention、decoder 输入
TimesNetFFT 周期发现 + 2D Inception 卷积rfft、周期 reshape、Conv2d、周期融合

6. 下一步阅读建议

  1. 先用 [[调试形参]] 跑通 TimesNet,并把断点打在 TimesNet.forward()TimesNet.forecast()TimesBlock.forward()FFT_for_Period()
  2. TimesBlock.forward() 内观察 period_list,确认不同 batch 下 period_weight 如何变化。
  3. 对比 PatchTST 的 patch 网格和 TimesNet 的周期网格:PatchTST 的二维结构来自滑窗切片,TimesNet 的二维结构来自 FFT 选周期后的重排。
  4. 最后回到论文,把 TimesNet 的创新点对应到三个代码点:FFT_for_Periodreshape(B,length//period,period,N)Inception_Block_V1

*记录并在线阅读我的笔记*