经典ABR算法介绍:Pensieve (SIGCOMM ‘17) 原理及训练指南

2024-01-18 20:12

本文主要是介绍经典ABR算法介绍:Pensieve (SIGCOMM ‘17) 原理及训练指南,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

  • 前言
  • Pensieve原理
  • *Pensieve重训练参考
    • Oboe [SIGCOMM '18]
    • Comyco [MM '19]
    • Fugu [NSDI '20]
  • A3C熵权重衰减
    • 思路
    • 实现


前言

Pensieve是DASH点播视频中最经典的ABR算法之一,也是机器学习类(Learning-based)ABR算法的代表性工作。Pensieve基于深度强化学习(DRL)方法A3C(Asynchronous Advantage Actor-Critic)设计,同时使用视频块的吞吐量历史采样、当前缓冲区等信息作为输入特征进行决策。与先前的启发式或基于领域知识的方法(如FESTIVE、BBA、BOLA、MPC等)不同,Pensieve利用强化学习模型自动在仿真环境中探索最优策略。

本文简要介绍Pensieve的基本原理。尽管Pensieve提供了开源代码,但由于深度强化学习的训练效果依赖于特定技巧,本文更为着重地介绍了应该如何正确地训练Pensieve模型,并将重训练Pensieve的代码、数据集、模型和结果进行了开源,参见:https://github.com/GreenLv/pensieve_retrain。

Pensieve论文:Neural Adaptive Video Streaming with Pensieve - SIGCOMM '17
Pensieve网站:Pensieve
Pensieve开源代码:hongzimao/pensieve: Neural Adaptive Video Streaming with Pensieve (SIGCOMM '17)

系列博文索引:

  • DASH标准&ABR算法介绍
  • dash.js的ABR逻辑
  • ABR算法研究综述阅读笔记
  • 经典ABR算法介绍:FESTIVE (CoNEXT '12) 论文阅读笔记
  • 经典ABR算法介绍:BBA (SIGCOMM ’14) 设计与代码实现
  • 经典ABR算法介绍:BOLA (INFOCOM '16) 核心算法逻辑
  • 经典ABR算法介绍:BOLA (INFOCOM '16) dash.js代码实现
  • 经典ABR算法介绍:Pensieve (SIGCOMM ‘17) 原理及训练指南

Pensieve原理

【注:Pensieve使用的A3C是一种Actor-Critic(AC)强化学习方法,背景知识及相关介绍参见:强化学习的数学原理学习笔记 - Actor-Critic,本文不再赘述。】

Actor-Critic原理:总体还是策略评估-策略提升的思想,其行为策略与目标策略一致,因此为on-policy方法

  • Critic网络:负责策略评估,估计当前Actor策略的状态值
  • Actor网络:负责策略提升,直接对应行为策略与目标策略,与环境交互获得经验采样,并不断更新优化目标策略

Pensieve使用两个神经网络,分别对应Actor与Critic,其特征及网络结构如下图所示。
在这里插入图片描述

A3C改进自经典AC算法A2C(Advantage Actor-Critic),主要差异在于支持异步(asynchronous)训练。特别地,Pensieve使用的A3C完全基于CPU训练,同时使用16个agent进行经验采样,并交由一个central agent对采样进行汇总并计算更新神经网络参数。此外,A3C在网络结构、策略评估等方面也有优化,并为Actor的训练引入了额外的熵正则化项。

Pensieve参数更新公式:

  • Critic网络: θ υ ← θ υ − α ′ ∑ t ∇ θ υ ( r t + γ V π θ ( s t + 1 ; θ υ ) − V π θ ( s t ; θ υ ) ) 2 \theta_\upsilon \larr \theta_\upsilon - \alpha' \sum_t \nabla_{\theta_\upsilon} (r_t + \gamma V^{\pi_\theta}(s_{t+1}; \theta_\upsilon) - V^{\pi_\theta}(s_{t}; \theta_\upsilon))^2 θυθυαtθυ(rt+γVπθ(st+1;θυ)Vπθ(st;θυ))2
  • Actor网络: θ ← θ + α ∑ t ∇ θ log ⁡ π θ ( s t , a t ) A ( s , a ) + β ∇ θ H ( π θ ( ⋅ ∣ s t ) ) \theta \larr \theta + \alpha \sum_t \nabla_\theta \log \pi_\theta (s_t, a_t) A(s, a) {\color{blue} +\beta \nabla_\theta H(\pi_\theta (\cdot | s_t) )} θθ+αtθlogπθ(st,at)A(s,a)+βθH(πθ(st))
    • 计算累积奖励相对于策略参数 θ \theta θ的梯度
    • 其中优势函数 A ( s , a ) A(s, a) A(s,a)基于Critic网络的输出(值函数的估计值)进行计算
    • β ∇ θ H ( π θ ( ⋅ ∣ s t ) ) \beta \nabla_\theta H(\pi_\theta (\cdot | s_t) ) βθH(πθ(st))为熵正则化项(由A3C引入)

优势函数(advantage function)表示在状态 s s s下,某个特定动作 a a a取得的奖励相对于整个策略 π θ \pi_\theta πθ的预期(平均)奖励的提升,形式为:
A π θ ( s t , a t ) = r t + γ V π θ ( s t + 1 ; θ υ ) − V π θ ( s t ; θ υ ) A^{\pi_\theta}(s_t, a_t) = r_t + \gamma V^{\pi_\theta}(s_{t+1}; \theta_\upsilon) - V^{\pi_\theta}(s_{t}; \theta_\upsilon) Aπθ(st,at)=rt+γVπθ(st+1;θυ)Vπθ(st;θυ)

  • 优势函数为正,表明当前动作 a a a优于现有策略,因此模型应该增强在当前状态下选择该动作的概率
  • 此时,策略参数 θ \theta θ应该向能够使得策略 π θ \pi_\theta πθ选择 a a a的概率最大的方向(即梯度方向)进行更新
  • 优势函数 A π θ ( s , a ) A^{\pi_\theta}(s, a) Aπθ(s,a) vs. 值函数 υ π θ ( s ) \upsilon^{\pi_\theta}(s) υπθ(s):通过估计值函数 V π θ ( s ; θ υ ) V^{\pi_\theta}(s; \theta_\upsilon) Vπθ(s;θυ)来估计优势函数

Pensieve参数设置:

  • k = 8 k=8 k=8:过去历史采样数量
  • γ = 0.99 \gamma = 0.99 γ=0.99:折扣因子,表示当前动作受未来100步的影响
  • α = 1 0 − 4 \alpha=10^{-4} α=104:Actor网络学习率
  • α ′ = 1 0 − 3 \alpha '=10^{-3} α=103:Critic网络学习率
  • β \beta β:熵因子,在 1 0 5 10^5 105次迭代中从 1 1 1衰减至 0.1 0.1 0.1【重要】
  • 1D CNN采用 128 128 128个filters(size 4 with stride 1)
  • 训练集占比:80%

Pensieve训练时间:

  • 单个算法:50000次迭代,每次迭代300ms(16个agent并行更新参数)
  • 总耗时:4小时左右

*Pensieve重训练参考

Pensieve的运行环境(参考:https://github.com/hongzimao/pensieve/issues/12#issuecomment-345060132)

Ubuntu 16.04, Tensorflow v1.1.0, TFLearn v0.3.1 and Selenium v2.39.0

有多篇工作对Pensieve进行了复现和对比,故可以作为重新训练Pensieve的参考资料。
对此部分细节不感兴趣的话可以跳过。主要结论是,重新训练Pensieve时最好按照原论文的描述实现熵权重的动态衰减,详见下一节内容。

Oboe [SIGCOMM '18]

论文:Oboe: auto-tuning video ABR algorithms to network conditions

Pensieve Re-Training and Validation. Before evaluating Pensieve on our dataset, we retrain Pensieve using the source code on the trace dataset provided by the Pensieve authors [11]. This helps us validate our retraining given that deep reinforcement learning results are not easy to reproduce [29].
We experimented with five different initial entropy weights in the author suggested range of 1 to 5, and linearly reduced their values in a gradual fashion using plateaus, with five different decrease rates until the entropy weight eventually reached 0.1. This rate scheduler follows best-practice [55]. From the trained set of models, we then selected the best performing model (an initial entropy weight of 1 reduced every 800 iterations until it reaches 0.1 over 100K iterations) and compared its performance to the pre-trained Pensieve model provided by the authors. Figure 10 shows CDFs of QoE-lin for the pretrained (Original) model and the model trained by us (Retrained). The performance distribution of the two models are almost identical over the test traces provided by the Pensieve authors, thereby validating our retraining methodology.
Having validated our retraining methodology, we trained Pensieve on our dataset with the same complete strategy described above. For this, we pick 1600 traces randomly from our dataset with average throughput in the 0-6 Mbps range. The number of training traces, the number of iterations per trace, and the range of throughput are similar to [39]. We then compare Pensieve and MPC+Oboe over a separate test set of traces also in the range of 0-6 Mbps (§4.2).

要点:

  • 改变熵因子参数设置,但最后的最优模型还是Pensieve原论文中的参数
  • 在Pensieve的原数据集上进行训练
  • 最终在相同测试集上与Pensieve表现基本一致
  • 重训练的数据集数量和迭代轮次与Pensieve原始模型接近

Comyco [MM '19]

论文:Comyco: Quality-Aware Adaptive Video Streaming via Imitation Learning

Pensieve Re-training. We retrain Pensieve via our datasets (§6.1), NN architectures (§4.1) and QoE metrics (§5.1). Followed by recent work [6], our experiments use different entropy weights in the range of 5.0 to 1.0 and dynamically decrease the weight every 1000 iterations. Training time takes about 8 hours and we show that Pensieve outperforms RobustMPC, with an overall average QoE improvement of 3.5% across all sessions. Note that same experiments can improve the Q o E l i n QoE_{lin} QoElin [51] by 10.5%. It indicates that Q o E v QoE_v QoEv cannot be easily improved because the metric reflects the real world MOS score.

要点:

  • 和Oboe一样,尝试了不同熵因子的取值
  • 但是只是用了Pensieve的A3C训练算法,神经网络结构和QoE指标都有改变
  • 训练时长比Pensieve原始模型更长

Fugu [NSDI '20]

论文:Learning in situ: a randomized experiment in video streaming

Deploying Pensieve for live streaming. We use the released Pensieve code (written in Python with TensorFlow) directly. When a client is assigned to Pensieve, Puffer spawns a Python subprocess running Pensieve’s multi-video model.
We contacted the Pensieve authors to request advice on deploying the algorithm in a live, multi-video, real-world setting. The authors recommended that we use a longer-running training and that we tune the entropy parameter when training the multi-video neural network. We wrote an automated tool to train 6 different models with various entropy reduction schemes. We tested these manually over a few real networks, then selected the model with the best performance. We modified the Pensieve code (and confirmed with the authors) so that it does not expect the video to end before a user’s session completes. We were not able to modify Pensieve to optimize SSIM; it considers the average bitrate of each Puffer stream. We adjusted the video chunk length to 2.002 seconds and the buffer threshold to 15 seconds to reflect our parameters. For training data, we used the authors’ provided script to generate 1000 simulated videos as training videos, and a combination of the FCC and Norway traces linked to in the Pensieve codebase as training traces.

This dataset shift could have harmed the performance of Pensieve, which was trained on the FCC traces. In response to reviewer feedback, we trained a version of Pensieve on throughput traces randomly sampled from real Puffer video sessions.

要点:

  • 调整了熵因子的选择,训练了多种不同模型
  • 调整了视频块时长、缓冲区阈值的设置
  • 使用Pensieve原本的网络数据集(FCC、Norway)进行训练(*后续使用了Puffer的数据集重新训练了Pensieve,性能有所提升)
  • 使用Pensieve原本的QoE的优化目标(码率),而非Fugu使用的SSIM
  • 重新训练Pensieve时按照论文提供了对于多视频的支持
  • 为了实现在Puffer上的部署,修改了部分Pensieve代码

A3C熵权重衰减

思路

Pensieve原始代码中,熵权重是固定的(ENTROPY_WEIGHT = 0.5),并非论文中描述的从1逐步衰减至0.1,代码如下:

ENTROPY_WEIGHT = 0.5
...
class ActorNetwork(object):"""Input to the network is the state, output is the distributionof all actions."""def __init__(self, sess, state_dim, action_dim, learning_rate):...# Compute the objective (log action_vector and entropy)self.obj = tf.reduce_sum(tf.multiply(tf.log(tf.reduce_sum(tf.multiply(self.out, self.acts),reduction_indices=1, keep_dims=True)),-self.act_grad_weights)) \+ ENTROPY_WEIGHT * tf.reduce_sum(tf.multiply(self.out,tf.log(self.out + ENTROPY_EPS)))

作者在Github中明确建议使用熵权重递减的策略来训练模型,见:https://github.com/hongzimao/pensieve/tree/master/sim

A general strategy to train our system is to first set ENTROPY_WEIGHT in a3c.py to be a large value (in the scale of 1 to 5) in the beginning, then gradually reduce the value to 0.1 (after at least 100,000 iterations).

Github的issue区有人提了类似的问题,参考:

  • Why the result is not better than MPC? · Issue #11 · hongzimao/pensieve
    • 很有价值的讨论过程,包括对Pensieve复现需要注意的细节以及部分复现结果
  • Changing ENTROPY WEIGHT with training · Issue #6 · hongzimao/pensieve
    • *这个问题是Oboe [SIGCOMM '18]的一作Zahaib Akhtar问的

作者说没有公开自动化熵权重衰减的原因,一是这个实现比较简单,二是希望大家复现的时候能观察到模型性能随着熵权重降低而逐步提高的过程。

[Author] Although we have our internal implementation (we didn’t post it because (1) it’s fairly easy to implement and (2) more importantly we intentionally want others to observe this effect), we would appreciate a lot if someone can reproduce and improve our implementation. Thanks!

关于自动化熵权重递减的讨论,部分内容摘录如下:

[Author] Did you load the trained model of previous run when you decay the factor? We (as well as others who reproduced it; some posts on issues already) didn’t do anything fancy, just plain decay once or twice should work.

[Questioner] I should stop the program, load the previous trained model, then re-run the python script. I’ve got good result by this way. But at first, I just set ENTROPY_WEIGHT as a member variable of Class actor, and changed its value during the while loop.

[Author] I think any reasonable decay function should work (e.g., linear, step function, etc.). … As for automatically decaying the exploration factor, notice that ENTROPY_WEIGHT sets a constant in tensorflow computation graph (e.g., https://github.com/hongzimao/pensieve/blob/master/sim/a3c.py#L47-L52)..) To make it tunable during execution, you need to specify a tensorflow placeholder and set its value each time.

要点:

  • 最直接的方法,就是手动控制训练过程,当其达到某个迭代次数的是时候手动停止训练并保存模型,手动修改a3c.py中的ENTROPY_WEIGHT值并基于先前的模型继续迭代训练
  • 自动化熵权重衰减需要通过在a3c.pyClass actor中预留placeholder,替代固定的ENTROPY_WEIGHT作为熵权重变量,并在multi_agent.pywhile循环中将具体的数值传入(随迭代轮数改变)
  • 任何形式的衰减(例如线性)都可以,作者称一到二次衰减效果就可以了

提问者进一步给出了效果不错的熵权重(初始值是5)衰减设置:

iterationENTROPY_WEIGHT
0-199995
20000-399994
40000-599993
60000-699992
70000-799991
80000-899990.5
90000-1000000.1

按照Pensieve原始论文和Oboe论文描述,考虑还是将1选为初始值,0.1选为100000次迭代后的最终值。或者可以选择1~5的初始值训练不同模型做性能对比。

实现

此部分具体实现参见:https://github.com/GreenLv/pensieve_retrain。除了熵权重衰减外,训练Pensieve还需要注意数据集划分、特征与奖励值归一化等问题,详见此Github仓库说明。

核心改动(1):在sim/a3c.py中,将原有的固定熵权重ENTROPY_WEIGHT改为变量entropy_weight

class ActorNetwork(object):"""Input to the network is the state, output is the distributionof all actions."""def __init__(self, sess, state_dim, action_dim, learning_rate):self.sess = sessself.s_dim = state_dimself.a_dim = action_dimself.lr_rate = learning_rate...# This gradient will be provided by the critic networkself.act_grad_weights = tf.placeholder(tf.float32, [None, 1])# dynamic entropy weightself.entropy_weight = tf.placeholder(tf.float32)# Compute the objective (log action_vector and entropy)self.obj = tf.reduce_sum(tf.multiply(tf.log(tf.reduce_sum(tf.multiply(self.out, self.acts),reduction_indices=1, keep_dims=True)),-self.act_grad_weights)) \+ self.entropy_weight * tf.reduce_sum(tf.multiply(self.out,tf.log(self.out + ENTROPY_EPS)))...

核心改动(2):在sim/a3c.py中,修改compute_gradientsActor.get_gradients的接口,将熵权重作为参数传入。

def compute_gradients(s_batch, a_batch, r_batch, terminal, actor, critic, entropy_weight):...actor_gradients = actor.get_gradients(s_batch, a_batch, td_batch, entropy_weight)critic_gradients = critic.get_gradients(s_batch, R_batch)return actor_gradients, critic_gradients, td_batch
class ActorNetwork(object):...def get_gradients(self, inputs, acts, act_grad_weights, entropy_weight):return self.sess.run(self.actor_gradients, feed_dict={self.inputs: inputs,self.acts: acts,self.act_grad_weights: act_grad_weights,self.entropy_weight: entropy_weight})

核心改动(3):在sim/multi_agent.py中,实现熵权重随迭代衰减的逻辑。
这里实现的方式是将初始值设为1,每10000次迭代将权重降低0.09,直到衰减至0.1为止。另外,也可以按照Github issue区的讨论从5开始分阶段衰减。

def calculate_entropy_weight(epoch):# entropy weight decay with iteration"""if epoch < 20000:entropy_weight = 5elif epoch < 40000:entropy_weight = 4elif epoch < 60000:entropy_weight = 3elif epoch < 70000:entropy_weight = 2elif epoch < 80000:entropy_weight = 1elif epoch < 90000:entropy_weight = 0.5else:entropy_weight = 0.1"""# initial entropy weight is 1, then decay to 0.1 in 100000 iterationsentropy_weight = 1 - (epoch / 10000) * 0.09if entropy_weight < 0.1:entropy_weight = 0.1return entropy_weight

核心改动(4):在sim/multi_agent.py中,随着迭代轮数计算熵权重,并传递给a3c进行梯度计算。

def central_agent(net_params_queues, exp_queues):...while True:...# assemble experiences from the agentsactor_gradient_batch = []critic_gradient_batch = []# decay entropy_weight with iteration (from 1 to 0.1) entropy_weight = calculate_entropy_weight(epoch)for i in xrange(NUM_AGENTS):s_batch, a_batch, r_batch, terminal, info = exp_queues[i].get()actor_gradient, critic_gradient, td_batch = \a3c.compute_gradients(s_batch=np.stack(s_batch, axis=0),a_batch=np.vstack(a_batch),r_batch=np.vstack(r_batch),terminal=terminal, actor=actor, critic=critic, entropy_weight=entropy_weight)...

这篇关于经典ABR算法介绍:Pensieve (SIGCOMM ‘17) 原理及训练指南的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/620132

相关文章

创建Java keystore文件的完整指南及详细步骤

《创建Javakeystore文件的完整指南及详细步骤》本文详解Java中keystore的创建与配置,涵盖私钥管理、自签名与CA证书生成、SSL/TLS应用,强调安全存储及验证机制,确保通信加密和... 目录1. 秘密键(私钥)的理解与管理私钥的定义与重要性私钥的管理策略私钥的生成与存储2. 证书的创建与

zookeeper端口说明及介绍

《zookeeper端口说明及介绍》:本文主要介绍zookeeper端口说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、zookeeper有三个端口(可以修改)aVNMqvZ二、3个端口的作用三、部署时注意总China编程结一、zookeeper有三个端口(可以

Python包管理工具pip的升级指南

《Python包管理工具pip的升级指南》本文全面探讨Python包管理工具pip的升级策略,从基础升级方法到高级技巧,涵盖不同操作系统环境下的最佳实践,我们将深入分析pip的工作原理,介绍多种升级方... 目录1. 背景介绍1.1 目的和范围1.2 预期读者1.3 文档结构概述1.4 术语表1.4.1 核

PowerShell中15个提升运维效率关键命令实战指南

《PowerShell中15个提升运维效率关键命令实战指南》作为网络安全专业人员的必备技能,PowerShell在系统管理、日志分析、威胁检测和自动化响应方面展现出强大能力,下面我们就来看看15个提升... 目录一、PowerShell在网络安全中的战略价值二、网络安全关键场景命令实战1. 系统安全基线核查

Java操作Word文档的全面指南

《Java操作Word文档的全面指南》在Java开发中,操作Word文档是常见的业务需求,广泛应用于合同生成、报表输出、通知发布、法律文书生成、病历模板填写等场景,本文将全面介绍Java操作Word文... 目录简介段落页头与页脚页码表格图片批注文本框目录图表简介Word编程最重要的类是org.apach

Python设置Cookie永不超时的详细指南

《Python设置Cookie永不超时的详细指南》Cookie是一种存储在用户浏览器中的小型数据片段,用于记录用户的登录状态、偏好设置等信息,下面小编就来和大家详细讲讲Python如何设置Cookie... 目录一、Cookie的作用与重要性二、Cookie过期的原因三、实现Cookie永不超时的方法(一)

Linux中压缩、网络传输与系统监控工具的使用完整指南

《Linux中压缩、网络传输与系统监控工具的使用完整指南》在Linux系统管理中,压缩与传输工具是数据备份和远程协作的桥梁,而系统监控工具则是保障服务器稳定运行的眼睛,下面小编就来和大家详细介绍一下它... 目录引言一、压缩与解压:数据存储与传输的优化核心1. zip/unzip:通用压缩格式的便捷操作2.

从原理到实战深入理解Java 断言assert

《从原理到实战深入理解Java断言assert》本文深入解析Java断言机制,涵盖语法、工作原理、启用方式及与异常的区别,推荐用于开发阶段的条件检查与状态验证,并强调生产环境应使用参数验证工具类替代... 目录深入理解 Java 断言(assert):从原理到实战引言:为什么需要断言?一、断言基础1.1 语

Java中的雪花算法Snowflake解析与实践技巧

《Java中的雪花算法Snowflake解析与实践技巧》本文解析了雪花算法的原理、Java实现及生产实践,涵盖ID结构、位运算技巧、时钟回拨处理、WorkerId分配等关键点,并探讨了百度UidGen... 目录一、雪花算法核心原理1.1 算法起源1.2 ID结构详解1.3 核心特性二、Java实现解析2.

Python中win32包的安装及常见用途介绍

《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作