论文:Progressive Pretext Task Learning for Human Trajectory Prediction

一、概述

渐进式预训练

主要特点

1.逐步增加复杂度,初期使用简单模型或者较小的数据集,随着训练的进行主键增加模型复杂度,如增加层或者神经元,或者扩展数据集的规模

2.分阶段训练,在每个阶段调整不同的参数或采用不同的训练策略

3.结合迁移学习,在一个相关任务上进行预训练,在该任务上学到的知识迁移到目标任务上

目前的应用

渐进式学习技术已在广泛的任务中得到探索,包括图像生成[11,14]、图像增强[7,22]、对象检测[4,8,16,29]和运动预测[24,40]。具体来说,Karras等人[14]提出从低分辨率图像开始,然后通过向网络添加层来逐步提高分辨率。PGBIG[24]利用多个阶段逐步完善对未来帧的初始猜测。Fu等人[7]介绍了一种用于低光图像增强的渐进式学习策略。在自我知识提炼的过程中,他们逐渐增加低光图像作为学生分支输入的比例,旨在逐步提高学生的学习难度。

11. Gregor, K., Danihelka, I., Graves, A., Rezende, D., Wierstra, D.: Draw: A recur
rent neural network for image generation. In: International conference on machine
learning. pp. 1462–1471. PMLR (2015)
14. Karras, T., Aila, T., Laine, S., Lehtinen, J.: Progressive growing of gans for im
proved quality, stability, and variation. arXiv preprint arXiv:1710.10196 (2017)
7. Fu, H., Zheng, W., Meng, X., Wang, X., Wang, C., Ma, H.: You do not need
additional priors or regularizers in retinex-based low-light image enhancement.
In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern
Recognition. pp. 18125–18134 (2023)
22. Liang, Z., Li, C., Zhou, S., Feng, R., Loy, C.C.: Iterative prompt learning for
unsupervised backlit image enhancement. In: Proceedings of the IEEE/CVF In
ternational Conference on Computer Vision. pp. 8094–8103 (2023)
4. Cai, Z., Vasconcelos, N.: Cascade r-cnn: Delving into high quality object detection.
In: Proceedings of the IEEE conference on computer vision and pattern recognition.
pp. 6154–6162 (2018)
8. Gidaris, S., Komodakis, N.: Object detection via a multi-region and semantic
segmentation-aware cnn model. In: Proceedings of the IEEE international con
ference on computer vision. pp. 1134–1142 (2015)
16.Komodakis, N., Gidaris, S.: Attend refine repeat: Active box proposal generation
via in-out localization. In: BMVC (2016)
29. Najibi, M., Rastegari, M., Davis, L.S.: G-cnn: an iterative grid based object de
tector. In: Proceedings of the IEEE conference on computer vision and pattern
recognition. pp. 2369–2377 (2016)
24. Ma, T., Nie, Y., Long, C., Zhang, Q., Li, G.: Progressively generating better initial
guesses towards next stages for high-quality human motion prediction. In: Proceed
ings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition.
pp. 6437–6446 (2022)
40. Tang, J., Sun, J., Lin, X., Zheng, W.S., Hu, J.F., et al.: Temporal continual learn
ing with prior compensation for human motion prediction. Advances in Neural
Information Processing Systems 36 (2024)

论文中模型特点

In our PPT framework, we further devise a novel Transformer-based trajectory predictor. Compared to previous Transformer predictors [9,12,34,53,55] that autoregressively generate the future positions, our model is able to efficiently predict the trajectory of any length in only two steps: determining the destination firstly and then generating the rest future points all at once. Specifically, our model consists of a destination predictor and a trajectory predictor. The former
predictor aims to capture long-term dependencies for predicting destinations, which are used to guide the latter one in generating the entire future trajectories. To achieve the efficient parallel generation of trajectory points, we introduce a series of learnable prompt embeddings to indicate the certain timesteps.

在我们的PPT框架中,我们进一步设计了一种新的基于Transformer的轨迹预测器。与之前的自回归生成未来位置的Transformer预测器[9,12,34,53,55]相比,我们的模型仅需两步即可有效地预测任何长度的轨迹:首先确定目的地,然后一次性生成其余的未来点。具体来说,我们的模型由目的地预测器和轨迹预测器组成。前者旨在捕捉预测目的地的长期依赖关系,用于指导后者生成整个未来轨迹。为了实现轨迹点的高效并行生成,我们引入了一系列可学习的提示嵌入来指示特定的时间步长。

二、方法

1.定义

对轨迹的表示,轨迹由多个点构成,每个点由xy坐标构成。轨迹分为两段,一段是过去的,一段是将要预测的

2.概况

Specifically, our framework consists of three stages of progressive training tasks, as illustrated in Figure 2 (b). In Stage I, we pretrain our predictor on pretext Task-I, aiming to fully understand the short-term dynamics of each trajectory, by predicting the next position of a trajectory of arbitrary
length. In Stage II, we further train this predictor on pretext Task-II, intending to capture the long-term dependencies, by predicting the destination of a trajectory. Once Task-I and Task-II are completed, the model is capable of capturing both the short-term dynamics and long-term dependencies within the trajectory. Finally, in Stage III, we duplicate our model to obtain two predictors: one for destination prediction and the other for intermediate waypoint prediction.
In this stage, we perform Task-III that enables the model to achieve the complete pedestrian trajectory prediction. For the sake of stable training, we further employ a cross-task knowledge distillation to avoid knowledge forgetting

具体来说,我们的框架由三个阶段的渐进式训练任务组成,如图2(b)所示。在第一阶段,我们以任务-I为借口预先训练我们的预测器,旨在通过预测任意长度轨迹的下一个位置,充分了解每个轨迹的短期动态。在第二阶段,我们以任务二为借口进一步训练这个预测器,旨在通过预测轨迹的目的地来捕捉长期依赖关系。一旦任务I和任务II完成,该模型就能够捕捉轨迹中的短期动态和长期依赖关系。最后,在第三阶段,我们复制我们的模型以获得两个预测器:一个用于目的地预测,另一个用于中间航路点预测。在这个阶段,我们执行任务III,使模型能够实现完整的行人轨迹预测。为了稳定的训练,我们进一步采用了跨任务知识蒸馏来避免知识遗忘

3.主干

上图中(c)transformer架构

输入:S^{T_m:T_n}

输出:S^{T_{m+1}:T_{n+1}}

经过:emb+N*(残差(layNorm+multi-head)+残差(layNorm+MLP))+layerNorm+Projector

4.Task

TaskI

捕捉短期动态,总轨迹S^{T_1:T_e},输入子序列S^{T_1:T_{t-1}}来预测S^{T_t}

In practice, multiple random subsequences would be sampled from one trajectory for improving training efficiency, and this can be effectively implemented by leveraging the causal self-attention mask

在实践中,将从一个轨迹中采样多个随机子序列以提高训练效率,这可以通过利用因果自我注意掩码来有效实现

模型记作\theta_I

Task-II

继续训练\theta_I,得到模型\theta_{II}

预测整个轨迹的目的地,论文中一次预测K个目的地

输入子序列S^{T_1:T_h}来预测最终的位置S^{T_e},经过MLP,最终变为预测K个位置

1)损失
损失1:精度损失

L_{Precison} = min_kL_2(\hat{E}_k,E)

只惩罚距离真实目的地E最近的预测点,确保至少有一个预测点接近真实位置

只优化最佳表现者

损失2:多样性损失

L_{Diversity} = \frac{1}{K(K-1)}\sum_{i}\sum_{j\neq i}e^{-\frac{L_2^2(\hat{E}_i,\hat{E}_j)}{\sigma _s}}

计算所有预测点两两之间的欧氏距离L2,通过高斯核e^{-\frac{distance^2}{\sigma_s}}惩罚距离过近的点对,距离越小,损失越大,\sigmas为缩放因子,强制K个预测点分散在不同位置,覆盖多模态可能性

总损失

L_{Des} = L_{Precision}+\lambda_dL_{Diversity}

\lambda _d平衡精度与多样性

2)跳跃式预测

常规序列按照时间步递归生成,属于自回归,每一步预测依赖前一步的输出

目的地预测直接从Th跳跃到Te,引入可学习提示嵌入,在历史轨迹S^{T_1:T_h}后添加一个可学习向量作为占位符,并把这个占位符赋予位置编码,使其对应倒数第二步的位置,模型将可学习向量视为T_{e-1}时刻的隐状态,直接输出目的地T_e

输入 [S_{T_1},S_{T_2},...,S_{T_h},[Prompt]]

位置编码 [P_1,P_2,...,P_h,P_{T_{e-1}}]

模型输出 预测P_{T_{e-1}}的下一个位置,即目的地P_e

Task-III

Trajectory Predictor和Destination Predictor都是任务II中模型\theta_{II}的复制

先使用目的地预测器生成K个候选目的地,然后将最接近地面实况(GT)的目的地输入轨迹预测器。轨迹预测器的输入序列可分为三部分:从T1到Th的观测轨迹、从Th+1到Te-1的未观测未来轨迹和Te的伪目的地。

对于未观察到的未来轨迹,我们使用可学习的提示嵌入作为输入。通过这些输入,轨迹预测器输出整个未来轨迹的2D位置,即S^{T_{h+1}:T_e}
在任务III期间,联合训练目的地预测器和轨迹预测器,回归整个未来轨迹。

为了避免之前借口任务中的知识被遗忘,我们在任务III中设计了一种跨任务知识蒸馏,以进行额外的正则化。具体来说,用以下损失函数惩罚θI和轨迹预测器之间的输出差异,以及θII和目的地预测器之间的差异:

 

损失函数使得任务I和任务III预测的轨迹保持一致。保持一致的并非轨迹坐标点本身,而是轨迹的抽象特征表示。F_I^t 和 F^t_{III}都是是高维特征向量,而非轨迹坐标(Task-III的主目标已是轨迹点预测,​直接约束点坐标会导致优化冲突;特征是高级抽象,包含更丰富的可迁移知识)。通常是解码器前的最后一层特征。

任务II和任务III预测的目的地一致。

P为线性投影层(全连接网络),对齐特征空间,因为模型结构差异可能导致特征维度不同。

使两个特征向量在投影空间中的欧氏距离最小化。

反向传播时,梯度仅更新 PtPd​ 和 θIII,θI 和θII参数冻结(类似教师模型,防止新任务的梯度破坏原有的知识,下文补充知识中详细介绍)

简单代码示意:

#冻结参数
for param in model_task1.parameters():
    param.requires_grad = False  
    
#前向传播时禁用梯度计算
@torch.no_grad()  # 上下文管理器确保无梯度
def get_teacher_features(history):
    features = model_task1.encoder(history)
    return features

本阶段的损失函数:

L_{Traj}是预测轨迹和地面真实轨迹之间的L2距离

5.推断

After training on all three tasks that progressively enable the model to predict
the entire future trajectory, we employ the well-trained destination predictor and
trajectory predictor in the final stage for inference. Specifically, we first utilize
the destination predictor to predict K destinations. Then, we take each of these
destinations as the input to the trajectory predictor, guiding the generation of
K future trajectories.

在对所有三个任务进行训练后,逐步使模型能够预测整个未来的轨迹,我们在最后阶段使用训练有素的目的地预测器和轨迹预测器进行推理。具体来说,我们首先利用目的地预测器来预测K个目的地。然后,我们将每个目的地作为轨迹预测器的输入,指导生成K个未来轨迹。

三、实验

基本设置

数据集

Stanford Drone Dataset (SDD) [33], ETH [31]/UCY [18]
dataset and Grand Central Station (GCS) [52] dataset.

评估指标

1.ADE (Average Displacement Error)

2.FDE (Final Displacement Error)

消融实验

渐进式预文本任务的效果

跨任务知识蒸馏 (知识蒸馏,Knowledge Distillation, KD)

多样性损失权重

该模型倾向于牺牲精度以最小化分集损失,导致预测精度降低。

有效性

定性结果

对比

四、总结

In this paper, we present a novel progressive pretext task learning (PPT) framework to formulate pedestrian trajectory prediction, addressing the limitations of previous works by effectively capturing short-term dynamics and long-term dependencies within trajectories. The PPT consists of three stages of progressive training tasks to enhance the model’s capacity. Task-I aims to equip the model with the basic ability to comprehend short-term dynamics inherent in the trajectories. Task-II intends to enhance the model to capture long-term dependencies. In Task-III, we finetune the model for the entire future trajectory prediction, exploiting the previously acquired knowledge. A cross-task knowledge distillation is introduced to preserve the knowledge from previous pretext tasks. Further, we design a Transformer-based predictor to complement our framework, which achieves great efficiency with a two-step inference. Extensive experiments are
conducted to demonstrate the superiority of our elaborately devised framework.

在这篇论文中,我们提出了一种新的渐进式借口任务学习(PPT)框架来制定行人轨迹预测,通过有效地捕捉轨迹内的短期动态和长期依赖关系来解决先前工作的局限性。PPT由三个阶段的渐进式训练任务组成,以提高模型的能力。任务I旨在使模型具备理解轨迹中固有的短期动态的基本能力。任务II旨在增强模型以捕捉长期依赖关系。
在任务III中,我们对整个未来轨迹预测的模型进行了微调,探索了之前获得的知识。引入了一种跨任务知识蒸馏,以保存来自先前借口任务的知识。此外,我们设计了一个基于Transformer的预测器来补充我们的框架,该框架通过两步推理实现了很高的效率。我们进行了广泛的实验来证明我们精心设计的框架的优越性。

补充知识1:自回归

自回归模型是逐步生成输出序列的,即每一步根据前面已经生成的部分和输入信息来预测下一个元素。

用掩码实现

mask = mask.fill_(float('-inf')).triu_(diagonal=1)  #上三角被设置为-inf,不包括主对角线

attn_scores = attn_scores + mask    # mask 的 shape 是 [seq_len, seq_len]

attn_probs = F.softmax(attn_scores, dim=-1)

输入偏移:将目标序列整体向右移动一个位置,作为解码器的输入

1.AR自回归模型

Yt有时间顺序,c为截距,最后一项为噪声项

一个自回归模型只能得出一个样本的结果,根据过去p个观测值

2.MA移动平均模型

噪声项求和,第一项为平均值

大部分时候时间序列应当是相对稳定的,在稳定的基础上,每个时间点上的标签值受过去一段时间内、不可预料的各种偶然事件影响而波动。MA模型是在试图用过去的"错误"或"冲击"来预测现在的值。

参数θ通过最大似然估计求解

误差项计算

1.条件似然法:假设初始误差项为0

2.精确似然法:将初始误差项作为带估计参数的一部分

利用模型结构和所有观测数据Y_1,Y_2...Y_T,来拟合估计模型参数(\mu,\theta_1,..,\theta_q)和初始项误差(\epsilon _1,...,\epsilon_{1-q}),通常通过卡尔曼滤波或状态空间模型实现,有效处理初始误差。计算通常通过最大似然估计优化.

3.ARIMA模型

全称为自回归差分移动平均模型(Autoregressive Integrated Moving Average Model)。ARIMA模型主要由三部分构成,分别为自回归模型(AR)、差分过程(I)和移动平均模型(MA)

(AR模型替代了原本的μ)

差分的阶数:相邻两个数作差

一阶:

二阶:

差分的滞后:相邻/相隔一个/相隔两个

非平稳时间序列用差分处理

时间序列的平稳性

自相关性指的是时间序列与其自身的滞后版本之间的相关性。具体来说,滞后kk的自相关系数表示的是序列中相隔kk个时间间隔的数据点之间的线性依赖程度

偏自相关性则是指在移除了中间时间点的影响后,时间序列中相隔kk个时间间隔的数据点之间的相关性。换句话说,它是度量当控制了中间时间点的影响之后,序列中两个点之间的直接相关性

非自回归模型尝试并行地生成整个输出序列,同时为所有的时间步生成输出。

补充知识2:跨任务知识蒸馏

解决持续学习中灾难性遗忘问题的关键技术。

当模型训练新任务时,会覆盖旧人物学到的参数,导致旧任务性能崩溃。

原因:神经网路参数共享机制和任务差异导致的梯度冲突

跨任务知识蒸馏和教师模型都涉及知识蒸馏,将一个大型的、复杂的模型(教师模型)学到的知识迁移到小的高效的模型(学生模型)上实现。传统的教师模型和学生模型通常执行相同的任务,在跨任务知识蒸馏中,可以处理不同的任务。教师模型的参数需要被冻结,防止知识漂移。

本论文中为异构教师

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐