Skip to Content
变形金刚权威指南 (Chinese Edition)
book

变形金刚权威指南 (Chinese Edition)

by Nicole Koenigstein
March 2026
Intermediate
372 pages
4h 53m
Chinese
O'Reilly Media, Inc.
Content preview from 变形金刚权威指南 (Chinese Edition)

第 2 章. 时间序列的Transformer

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

由于Transformer( )模型比循环神经网络(RNN)模型更能有效捕捉长序列交互,因此在时间序列建模中广受欢迎。 Transformer 中的自注意力机制允许序列中的每个元素直接关注其他所有元素,从而将网络信号传播路径的最大长度缩减至理论上的最小值 O(1)。这消除了对循环结构的需求,并实现了更高效的信息流。因此,Transformer 在长序列时间序列预测(LSTF) 以及异常检测和时空时间序列预测等其他领域展现出巨大潜力。

许多实际应用,如天气预报、交通预测、工业过程控制和电力消耗规划,都需要对长序列时间序列进行预测。LSTF 要求模型具备高预测能力,能够高效捕捉输入与输出之间的精确长程依赖关系。

此外,概率时间序列预测是许多实际应用中的重要任务,从金融和天气预报到计算机系统性能管理皆是如此。在这些领域,准确的概率预测对于做出明智决策至关重要。概率时间序列预测( )涵盖了所有可能未来结果的概率范围,而非将单一特定结果视为“预测结果”。

在本章的学习过程中,您将了解使用时间序列数据时需要考虑的关键因素。 您还将对时间序列的不同应用领域建立基础认知, 例如时间序列预测、异常检测以及时空时间序列预测。作为本章学习之旅的最后环节,您将考察适用于这些领域的不同Transformer架构,包括Chronos、PatchTST和AnomalyBERT,并学习如何针对您的数据对前两个模型进行微调。

理解时间序列数据的复杂性

在 处理时间序列数据时,必须考虑某些关键属性,这些属性会对您的分析和预测产生重大影响。本节简要概述了处理时间序列数据时应重点考察的常见属性。

自相关与偏自相关

自相关( )是指时间序列中观测值之间的内部相关性,通常表示为观测值之间时间间隔的函数。滞后自相关的数学定义 k时的自相关,y(k), 如下所示:

γ(k)=E(Xtμ)(Xt+kμ)E(Xtμ)2,

这里, Xt,t=0,±1,±2, 表示数列的值,而 μ 表示序列的均值。期望值用符号 E。该样本的样本统计量可通过以下公式计算:

γ^(k)=i=1nk(xtx¯)(xt+kx¯)i=1n(xtx¯)2,

x¯ 是观测值的均值, x1,x2,,xn, 该时间序列的。

时间序列k 的滞后,定义为 ytytk,而其他变量的影响则偏移了 k 滞后 (yt1,yt2,,ytk+1). 自相关函数和偏自相关函数常被统称为相关图。图2-1展示了 亚马逊股价 的相关图( )。

Correlogram showing high autocorrelation at all lags and significant partial autocorrelation at the first lag for Amazon stock prices, with confidence bands indicating statistical significance.
图 2-1. 亚马逊股票的相关图

自相关图(左图)的横轴显示了时间序列各元素之间的滞后量。例如,滞后2的自相关是指时间序列与其两个时间周期前观测到的对应元素之间的相关性。观察自相关图可发现,序列的当前时间步与前一时间步之间存在高度自相关,且无衰减趋势。 此外,部分自相关(右图)在第一个滞后阶上显著。灰色区域为置信区间, 表明相关性是否具有统计学意义 。

协整

协整 指两个时间序列之间的真实关系。一个常用的例子是醉酒的行人及其宠物狗。如果单独观察,他们各自的行走轨迹可能看似随机,但彼此之间从未偏离得太远。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

LLM 网格 (Chinese Edition)

LLM 网格 (Chinese Edition)

Kurt Muehmel

Publisher Resources

ISBN: 0642572364274