-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrl-rough-reading.html
1869 lines (1248 loc) · 88.6 KB
/
rl-rough-reading.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="theme-next mist use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
<meta name="google-site-verification" content="zu-9nWphPjrzXV8v514mkHknIz4dNfHlib56-KNAu44">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">
<script src="/lib/pace/pace.min.js?v=1.0.2"></script>
<link href="/lib/pace/pace-theme-flash.min.css?v=1.0.2" rel="stylesheet">
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
<script>
(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/356f1943.js","daovoice")
daovoice('init', {
app_id: "356f1943"
});
daovoice('update');
</script>
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">
<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png?v=5.1.4">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32png?v=5.1.4">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png?v=5.1.4">
<link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">
<meta name="keywords" content="rl,">
<link rel="alternate" href="/atom.xml" title="Keavnn'Blog" type="application/atom+xml">
<script>
(function(){
if(''){
if (prompt('请输入文章密码','') !== ''){
alert('密码错误!');
history.back();
}
}
})();
</script>
<meta name="description" content="本文记录了一些粗读的强化学习相关的论文。">
<meta name="keywords" content="rl">
<meta property="og:type" content="article">
<meta property="og:title" content="强化学习论文浅读集合">
<meta property="og:url" content="http://StepNeverStop.github.io/rl-rough-reading.html">
<meta property="og:site_name" content="Keavnn'Blog">
<meta property="og:description" content="本文记录了一些粗读的强化学习相关的论文。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/gorila.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/gorila-pseudo.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/mb-mpo-pseudo.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/mb-mpo-visio.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/skill.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/Agakov.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/diayn-pseudo.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/diayn.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/ere-pseudo.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/6san.png">
<meta property="og:image" content="http://stepneverstop.github.io/rl-rough-reading/MANet-structure.png">
<meta property="og:updated_time" content="2020-04-11T04:00:03.946Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="强化学习论文浅读集合">
<meta name="twitter:description" content="本文记录了一些粗读的强化学习相关的论文。">
<meta name="twitter:image" content="http://stepneverstop.github.io/rl-rough-reading/gorila.png">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Mist',
version: '5.1.4',
sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":true},
fancybox: true,
tabs: true,
motion: {"enable":true,"async":true,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
duoshuo: {
userId: '0',
author: '博主'
},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<link rel="canonical" href="http://StepNeverStop.github.io/rl-rough-reading.html">
<title>强化学习论文浅读集合 | Keavnn'Blog</title>
</head>
<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">
<div class="container sidebar-position-left page-post-detail">
<div class="headband"></div>
<a href="https://github.com/StepNeverStop" class="github-corner" aria-label="View source on GitHub" rel="external nofollow" target="_blank"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Keavnn'Blog</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<h1 class="site-subtitle" itemprop="description">If it is to be, it is up to me.</h1>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br>
首页
</a>
</li>
<li class="menu-item menu-item-about">
<a href="/about/" rel="section">
<i class="menu-item-icon fa fa-fw fa-user"></i> <br>
关于
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
标签
</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br>
分类
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
归档
</a>
</li>
<li class="menu-item menu-item-search">
<a href="javascript:;" class="popup-trigger">
<i class="menu-item-icon fa fa-search fa-fw"></i> <br>
搜索
</a>
</li>
</ul>
<div class="site-search">
<div class="popup search-popup local-search-popup">
<div class="local-search-header clearfix">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<span class="popup-btn-close">
<i class="fa fa-times-circle"></i>
</span>
<div class="local-search-input-wrapper">
<input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
</div>
</div>
<div id="local-search-result"></div>
</div>
</div>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<div id="posts" class="posts-expand">
<article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://StepNeverStop.github.io/rl-rough-reading.html">
<span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
<meta itemprop="name" content="Keavnn">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/Kicon.jpg">
</span>
<span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Keavnn'Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">强化学习论文浅读集合</h2>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2019-06-10T15:55:29+08:00">
2019-06-10
</time>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于:</span>
<time title="更新于" itemprop="dateModified" datetime="2020-04-11T12:00:03+08:00">
2020-04-11
</time>
</span>
<span class="post-category">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
<a href="/categories/ReinforcementLearning/" itemprop="url" rel="index">
<span itemprop="name">ReinforcementLearning</span>
</a>
</span>
</span>
<div class="post-wordcount">
<span class="post-meta-item-icon">
<i class="fa fa-file-word-o"></i>
</span>
<span class="post-meta-item-text">字数统计:</span>
<span title="字数统计">
9.6k
</span>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-clock-o"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span title="阅读时长">
38
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>本文记录了一些粗读的强化学习相关的论文。</p>
<a id="more"></a>
<h1 align="center" style="color:blue" id="Gorila">[DeepMind]Massively Parallel Methods for Deep Reinforcement Learning[Gorila]</h1>
<p>本文提出了一个分布式强化学习训练的架构:Gorila(General Reinforcement Learning Architecture)。2015年发于ICML,本文使用DQN算法进行分布式实现。</p>
<p>论文地址:<a href="https://arxiv.org/pdf/1507.04296.pdf" rel="external nofollow" target="_blank">https://arxiv.org/pdf/1507.04296.pdf</a></p>
<h2 id="模型示意图"><a href="#模型示意图" class="headerlink" title="模型示意图"></a>模型示意图</h2><p><img src="./rl-rough-reading/gorila.png" alt=""></p>
<p>解析:</p>
<ul>
<li>shard代表参数分片的意思,即模型过大、参数过多,需要将参数分片放置多台机器上</li>
<li>Bundled Mode模式指的是Actor中的Q网络与Learner中的Q网络一样,但是Learner比Actor多了一个目标Q网络,用于计算梯度</li>
</ul>
<h2 id="特点"><a href="#特点" class="headerlink" title="特点"></a>特点</h2><ul>
<li>并行Actor采数据</li>
<li>并行Learner计算梯度,<strong>不更新Learner中的模型</strong></li>
<li>中心参数服务器,用于维持最新的网络模型。如果模型太大、参数过多,可以分片将网络模型放置多个参数服务器,每个参数服务器中的参数独立不关联,根据learner传的梯度更新相应的变量</li>
<li>经验池机制,分为local与global两种<ul>
<li>local,即每个actor节点一个经验池</li>
<li>global,将所有actor节点的经验存至一个分布式数据库中,这个<strong>需要网络通信开销</strong></li>
</ul>
</li>
</ul>
<h2 id="伪代码"><a href="#伪代码" class="headerlink" title="伪代码"></a>伪代码</h2><p><img src="./rl-rough-reading/gorila-pseudo.png" alt=""></p>
<p>解析:</p>
<ul>
<li><p>伪代码中为一个actor节点的流程</p>
</li>
<li><p>注意伪代码中出现两次<code>Update θ from parameters θ+ of the parameter server</code>,这句话的意思为从中心参数服务器拉取模型到actor和learner,拉取的时间点为:</p>
<ul>
<li>每个episode开始前</li>
<li>每次执行动作$a_{t}$后,但是在计算梯度并将梯度传递至参数服务器之前</li>
</ul>
</li>
<li><p>伪代码中<code>equation 2</code>,代表$g_{i}=\left(r+\gamma \max _{a^{\prime}} Q\left(s^{\prime}, a^{\prime} ; \theta_{i}^{-}\right)-Q\left(s, a ; \theta_{i}\right)\right) \nabla_{\theta_{i}} Q(s, a ; \theta)$,这是DQN中的损失函数</p>
</li>
<li><p>注意,与传统DQN不同的是,<strong>该分布式DQN中给Learner中的目标Q网络赋值时,是直接将更新N次的中心参数服务器中的模型进行拉取覆盖,而不是使用Learner中的Q网络</strong></p>
</li>
<li><p>中心参数服务器中的参数梯度更新需要累计多个learner传来的梯度后进行更新,使用异步SGD即ASGD方法进行梯度下降。</p>
<ul>
<li><blockquote>
<p>The parameter server then applies the updates that are accumulated from many learners. </p>
</blockquote>
</li>
</ul>
</li>
<li><p>因为每个actor都是阶段更新自己的模型,即从参数服务器中拉取。所以每个actor中的行为策略(采样策略)都不完全相同,事实上,每个actor节点可以采取不同的探索机制,这样可以更有效地探索环境</p>
</li>
</ul>
<h2 id="稳定性"><a href="#稳定性" class="headerlink" title="稳定性"></a>稳定性</h2><p>为了应对节点退出、网速慢、节点机器运行慢等问题,该文章中指出使用了一个超参数用来控制actor和server之间最大延时。</p>
<ul>
<li><p>过时的梯度(低于时间阈值)将会被丢弃</p>
<ul>
<li><blockquote>
<p>All gradients older than the threshold are discarded by the parameter server. </p>
</blockquote>
</li>
</ul>
</li>
<li><p>过高或过低的梯度也将被丢弃</p>
<ul>
<li><blockquote>
<p>each actor/learner keeps a running average and standard deviation of the absolute DQN loss for the data it sees and discards gradients with absolute loss higher than the mean plus several standard deviations. </p>
</blockquote>
</li>
</ul>
</li>
<li><p>使用AdaGrad更新规则</p>
</li>
</ul>
<h2 id="效果"><a href="#效果" class="headerlink" title="效果"></a>效果</h2><p>采用于提出DQN的论文中一样的网络结构,具体请见论文中第5部分。</p>
<p>在Atari 2600 49个游戏中,41个明显优于单GPU DQN。</p>
<p>Gorila进一步实现了DRL的希望:一个可伸缩的架构,随着计算和内存的增加,它的性能会越来越好</p>
<h1 align="center" style="color:blue" id="MB-MPO">[UCB/OpenAI]Model-Based Reinforcement Learning via Meta-Policy Optimization[MB-MPO]</h1>
<p>论文地址:<a href="https://arxiv.org/pdf/1809.05214.pdf" rel="external nofollow" target="_blank">https://arxiv.org/pdf/1809.05214.pdf</a></p>
<p>本文2018年发布于CoRL,提出了一个基于模型的元强化学习算法MB-MPO。相比于一般的元强化学习是从多个MDPs任务中学习一个通用模型加速以后特定任务的模型训练,该文中的方法是将一个model-free的任务学习多个不确定、不完全、不完美的动态模型,即一个模型集合,然后使用这个模型集合学习出该任务的通用模型。因为它有一个从model-free学习动态模型的过程,所以为model-based方法。</p>
<h2 id="元强化学习"><a href="#元强化学习" class="headerlink" title="元强化学习"></a>元强化学习</h2><script type="math/tex; mode=display">
\max _{\theta} \mathbb{E}_{\mathcal{M}_{k} \sim \rho(\mathcal{M}),\boldsymbol{s}_{t+1} \sim p_{k},\boldsymbol{a}_{t} \sim \pi_{\boldsymbol{\theta}^{\prime}}\left(\boldsymbol{a}_{t} | \boldsymbol{s}_{t}\right)}\left[\sum_{t=0}^{H-1} r_{k}\left(s_{t}, a_{t}\right)\right] \\ s.t.:\boldsymbol{\theta}^{\prime}=\boldsymbol{\theta}+\alpha\nabla_{\boldsymbol{\theta}} \mathbb{E}_{\boldsymbol{s}_{t+1} \sim p_{k},\boldsymbol{a}_{t} \sim \pi_{\boldsymbol{\theta}}\left(\boldsymbol{a}_{t} | \boldsymbol{s}_{t}\right)}\left[\sum_{t=0}^{H-1} r_{k}\left(s_{t}, a_{t}\right)\right]</script><p>$\mathcal{M}$为一系列MDP,共享相同的状态空间$\mathcal{S}$与动作空间$\mathcal{A}$,但是奖励函数可以不同</p>
<h2 id="学习环境动态模型"><a href="#学习环境动态模型" class="headerlink" title="学习环境动态模型"></a>学习环境动态模型</h2><script type="math/tex; mode=display">
\min _{\boldsymbol{\phi}_{k}} \frac{1}{\left|\mathcal{D}_{k}\right|} \sum_{\left(\boldsymbol{s}_{t}, \boldsymbol{a}_{t}, \boldsymbol{s}_{t+1}\right) \in \mathcal{D}_{k}}\left\|\boldsymbol{s}_{t+1}-\hat{f}_{\boldsymbol{\phi}_{k}}\left(\boldsymbol{s}_{t}, \boldsymbol{a}_{t}\right)\right\|_{2}^{2}</script><p>解析:</p>
<ul>
<li><p>$\mathcal{D}_{k}$为第k个学习模型采样的“经验”</p>
</li>
<li><p>$\phi$为用神经网络表示的环境模型的参数</p>
</li>
<li><p>$\hat{f}_{\boldsymbol{\phi}_{k}}\left(\boldsymbol{s}_{t}, \boldsymbol{a}_{t}\right)$为第k个学习模型针对状态$s_{t}$执行动作$a_{t}$后转移状态的预测,其中,神经网络的输出不直接是预测的状态$\color{red}{s_{t+1}}$,而是$\color{red}{\Delta s=s_{t+1}-s_{t}}$,所以$\hat{f}_{\boldsymbol{\phi}_{k}}\left(\boldsymbol{s}_{t}, \boldsymbol{a}_{t}\right)=s_{t}+\Delta s$</p>
<ul>
<li><blockquote>
<p>We follow the standard practice in model-based RL of training the neural network to predict the change in state $\Delta s=s_{t+1}-s_{t}$ (rather than the next state $s_{t+1}$) </p>
</blockquote>
</li>
</ul>
</li>
</ul>
<p>为了防止过拟合,文中使用了3个trick:</p>
<ol>
<li>早停</li>
<li>归一化神经网络输入与输出</li>
<li>权重归一化</li>
</ol>
<h2 id="基于环境动态模型的元强化学习"><a href="#基于环境动态模型的元强化学习" class="headerlink" title="基于环境动态模型的元强化学习"></a>基于环境动态模型的元强化学习</h2><p>假设学到了K个近似模型$\left\{\hat{f}_{\phi_{1}}, \hat{f}_{\phi_{2}}, \ldots, \hat{f}_{\phi_{K}}\right\}$,把每个模型转换成一个MDP过程,即$\mathcal{M}_{k}=\left(S, A, \hat{f}_{\phi_{k}}, r, \gamma, p_{0}\right)$,其中,<strong>奖励函数相同</strong></p>
<p>由此给每个学习到的动态模型分配的行为策略目标函数为:</p>
<script type="math/tex; mode=display">
J_{k}(\boldsymbol{\theta})=\mathbb{E}_{\boldsymbol{a}_{t} \sim \pi_{\boldsymbol{\theta}}\left(\boldsymbol{a}_{t} | s_{t}\right)}\left[\sum_{t=0}^{H-1} r\left(\boldsymbol{s}_{t}, \boldsymbol{a}_{t}\right) | \boldsymbol{s}_{t+1}=\hat{f}_{\boldsymbol{\phi}_{k}}\left(\boldsymbol{s}_{t}, \boldsymbol{a}_{t}\right)\right]</script><p>定义MB=MPO的最终目标函数为:</p>
<script type="math/tex; mode=display">
\max _{\boldsymbol{\theta}} \frac{1}{K} \sum_{k=0}^{K} J_{k}\left(\boldsymbol{\theta}_{k}^{\prime}\right) \quad \text { s.t.: } \quad \boldsymbol{\theta}_{k}^{\prime}=\boldsymbol{\theta}+\alpha \nabla_{\boldsymbol{\theta}} J_{k}(\boldsymbol{\theta})</script><p>小写k代表第k个学到的模型,大写K代表模型的总数。</p>
<p>注意看,这里公式后边使用的是$\color{red}{\theta’_{k}}$,而不是$\theta$。这里并没有写错,我起初以为写错了,具体请看后边的伪代码解释。</p>
<h2 id="伪代码-1"><a href="#伪代码-1" class="headerlink" title="伪代码"></a>伪代码</h2><p><img src="./rl-rough-reading/mb-mpo-pseudo.png" alt=""></p>
<p>解析:</p>
<ul>
<li>MB-MPO分为两部分更新,第一部分更新每个模型分配的行为策略,第二部分更新元策略。<strong>注意:行为策略的更新是不连贯的,即不是自身迭代,而是不断使用元策略进行稍加修改然后替换,所以叫做adapted policy</strong></li>
<li>上一项提到的两次更新都是对元策略的参数$\theta$进行更新,区别是,第一次更新将更新后的参数赋值给了行为策略,未更改元策略本身,第二次更新直接更新元策略本身</li>
<li>$\alpha, \beta$为两部分更新的学习率</li>
<li>行为策略使用VPG,即传统策略梯度算法进行优化,元策略使用TRPO算法进行优化</li>
<li>伪代码中的大致流程如下:<ol>
<li>初始化策略$\pi_{\theta}$并将其复制K份$\pi_{\theta_{1}^{\prime}}, \dots, \pi_{\boldsymbol{\theta}_{K}^{\prime}}$</li>
<li>使用$\pi_{\theta_{1}^{\prime}}, \dots, \pi_{\boldsymbol{\theta}_{K}^{\prime}}$对<strong>真实的环境模型进行采样(这一步是实际交互,即真实数据)</strong>,将数据存入经验池</li>
<li>根据经验池训练K个环境模型,即使用<code>学习环境动态模型</code>部分的公式</li>
<li>对于每个更新后的环境模型,用元策略$\color{red}{\pi_{\theta}}$进行<strong>虚拟采样(这一步是预测采样,即不实际进行交互)</strong>,采样到$\mathcal{T}_{k}$以适应性修改行为策略$\boldsymbol{\theta}_{k}^{\prime}$。这里也是前边提到的行为策略更新是不连贯的原因。</li>
<li>再用适应性策略$\boldsymbol{\theta}_{k}^{\prime}$进行<strong>虚拟采样</strong>,采样到$\mathcal{T}_{k}^{\prime}$以更新元策略$\pi_{\theta}$</li>
<li>跳向第2步</li>
</ol>
</li>
<li>伪代码中虽然没有明确指出,但是其实使用了baseline的trick用来减少方差</li>
</ul>
<h2 id="流程示意图"><a href="#流程示意图" class="headerlink" title="流程示意图"></a>流程示意图</h2><p><img src="./rl-rough-reading/mb-mpo-visio.png" alt=""></p>
<h2 id="效果-1"><a href="#效果-1" class="headerlink" title="效果"></a>效果</h2><ol>
<li>比之前的model-based方法效果好、收敛快</li>
<li>可以达到model-free算法的渐进性能</li>
<li>需要更少的经验,低采样复杂性。其实是使用了虚拟采样,提高了数据效率,减少了交互采样的代价。</li>
<li>对于模型偏差(model-bias,即环境模型没学到位)的情况,之前的算法不能有效处理,该算法对不完美、不完全、不完整的模型具有很好地鲁棒性</li>
</ol>
<h1 align="center" style="color:blue" id="DIAYN">[UCB/Google AI]Diversity is All Your Need: Learning Skills Without a Reward Function[DIAYN]</h1>
<p>论文地址:<a href="https://arxiv.org/pdf/1802.06070.pdf" rel="external nofollow" target="_blank">https://arxiv.org/pdf/1802.06070.pdf</a></p>
<p>Google网页:<a href="https://sites.google.com/view/diayn/home" rel="external nofollow" target="_blank">https://sites.google.com/view/diayn/home</a></p>
<p>Github项目:<a href="https://github.com/ben-eysenbach/sac/blob/master/DIAYN.md" rel="external nofollow" target="_blank">https://github.com/ben-eysenbach/sac/blob/master/DIAYN.md</a></p>
<p>这篇文章使用信息论中最大熵的方法来构造强化学习的学习目标,<strong>期望学习到具有多样性的技能(skills)</strong>。</p>
<p>个人认为,此文章中所提的方法虽然很新颖,但是不能作为优化一项任务的可用算法,因为虽然其可以学到以各种花样完成目标,但是没有奖励函数的控制使得无法规范、指引智能体“解题”过程的效果,如柔顺性、实用性、实际可行性等。从另一方面来讲,将这样虽然不规划、不严谨决策行为的策略用于元策略的预训练模式还是可用的。</p>
<h2 id="技能"><a href="#技能" class="headerlink" title="技能"></a>技能</h2><p>技能的定义在文中有如下表述:</p>
<blockquote>
<p>A skill is a latent-conditioned policy that alters that state of the environment in a consistent<br>way.<br>we refer to a/the policy conditioned on a fixed Z as a “skill” .</p>
</blockquote>
<p>意思是,设定一个隐变量,以(状态$S$,隐变量$Z$)为条件进行动作选择,即为技能——skill。</p>
<p>DIAYN就好像是要给每个状态赋予各个不同技能的概率,并且使其中一个技能的概率最大,这样就使得在整个状态空间中,不同的技能“占领”着状态空间的不同部分,每个技能在各自偏好的局部状态空间中作用,但是作者同样希望每个技能在各自的状态空间中尽可能随机决策。</p>
<p><img src="./rl-rough-reading/skill.png" alt=""></p>
<p>假设以不同的颜色代表不同的技能skill,每个方格代表一个状态,那么每个状态对于每个技能到达此状态的“偏好”概率是不同的。总的来说,作者希望技能之间的重合度尽可能小,但每个技能在各自的领域内尽可能随机地完成目标。</p>
<h2 id="亮点与作用"><a href="#亮点与作用" class="headerlink" title="亮点与作用"></a>亮点与作用</h2><ol>
<li>去掉了奖励函数</li>
<li>修改了目标函数,$\mathcal{F}(\theta)\triangleq \mathcal{G}(\color{red}{\theta, \phi})$<ul>
<li>$\color{red}{\theta}$代表Actor网络中的参数</li>
<li>$\color{red}{\phi}$代表Critic网络中的参数</li>
</ul>
</li>
<li>学习到的技能可以用于<em>分层强化学习、迁移学习、模仿学习</em></li>
</ol>
<h2 id="目标函数"><a href="#目标函数" class="headerlink" title="目标函数"></a>目标函数</h2><script type="math/tex; mode=display">
\begin{aligned}
\mathcal{F}(\theta) & \triangleq \color{red}{I(S ; Z)+\mathcal{H}[A | S]-I(A ; Z | S)} \\
&=(\mathcal{H}[Z]-\mathcal{H}[Z | S])+\mathcal{H}[A | S]-(\mathcal{H}[A | S]-\mathcal{H}[A | S, Z]) \\
&=\color{blue}{\mathcal{H}[Z]-\mathcal{H}[Z | S]+\mathcal{H}[A | S, Z]} \\
&=\mathcal{H}[A | S, Z]+\mathbb{E}_{z \sim p(z), s \sim \pi(z)}[\log p(z | s)]-\mathbb{E}_{z \sim p(z)}[\log p(z)] \\
&{ \color{orange}{\geq} \mathcal{H}[A | S, Z]+\mathbb{E}_{z \sim p(z), s \sim \pi(z)}\left[\log q_{\phi}(z | s)-\log p(z)\right] \\
\triangleq \mathcal{G}(\theta, \phi)}
\end{aligned}</script><p>解析:</p>
<ul>
<li><p>互信息,离散下为$I(X ; Y)=\sum_{y \in Y} \sum_{x \in X} p(x, y) \log \left(\frac{p(x, y)}{p(x) p(y)}\right)$,连续下为$I(X ; Y)=\int_{Y} \int_{X} p(x, y) \log \left(\frac{p(x, y)}{p(x) p(y)}\right) d x d y$</p>
</li>
<li><p>信息熵表示为$H(X, Y)=-\sum_{x, y} p(x, y) \log p(x, y)=-\sum_{i=1}^{n} \sum_{j=1}^{m} p\left(x_{i}, y_{i}\right) \log p\left(x_{i}, y_{i}\right)$</p>
</li>
<li><p>推到中频繁使用了性质$I(X,Y)=H(X)-H(X | Y)$</p>
</li>
<li><p>式中对数的底为自然指数$e$</p>
</li>
<li><p>看红色部分,化简之前:</p>
<ul>
<li><strong>增大</strong>:$I(S ; Z)$代表状态$S$与策略隐变量$Z$之间的互信息。因为作者希望可以通过策略所能到达的状态来判别其属于哪个技能,即将技能与状态挂钩。作者给出一个直观的解释:因为在有些状态下可以执行很多动作,但是却不改变环境(至少不明显改变),就像用机械手臂夹紧一个物体时,可使用力的大小、方向等都是很多的,不同技能选择不同动作导致的效果可能相同,所以作者不希望从动作的选择来区分学到的技能,而是通过可以明显观察到、数值化的状态$S$来作为区别不同技能的标准。<strong>互信息$I(X,Y)$有一个直观的性质就是,它可以衡量两个随机变量的“相关性”,也就是说,互信息越大,代表知道$X$后对$Y$的不确定性减少,即知道其一可以加深对另一个的了解。</strong>所以,目标函数希望最大化互信息$I(S ; Z)$,以将状态和技能相关联,使技能尽可能根据状态可以区分。</li>
<li><strong>增大</strong>:$\mathcal{H}[A | S]$代表策略(不以隐变量$Z$区分技能,混合所有技能即为策略)的熵值。与SAC算法中想要使用熵增来使得动作的选择更加随机一样,作者希望随机性的动作同样可以完成目标,所以希望尽可能增大这一项。</li>
<li><strong>减小</strong>:$I(A ; Z | S)$代表动作$A$与策略隐变量$Z$在给定状态$S$时之间的互信息。为了避免歧义,应该写作为$I[(A ; Z) | S]$。作者希望技能根据状态可区分,而不是根据动作,所以需要最小化这一项。</li>
</ul>
</li>
<li><p>看蓝色部分,化简之后:</p>
<ul>
<li><strong>固定最大,为$\ln n$</strong>:$\mathcal{H}[Z]$代表技能分布的不确定性,既然要最大化这个项,不如就固定它,使得技能从其中均匀采样,使熵为最大值。</li>
<li><strong>减小</strong>:$\mathcal{H}[Z | S]$代表状态$S$条件下技能的不确定性,我们知道,熵越大,不确定性越大;熵越小,不确定性越小。作者希望技能根据状态可区分,可以需要使这一项最小,以减小给定状态下所属技能的不确定性,使其尽可能接近概率1。</li>
<li><strong>增大</strong>:$\mathcal{H [ A | S}, Z ]$代表给定技能$(S,Z)$下动作的不确定性。因为作者希望动作的选择尽可能随机但又可以完成目标,所以需要最大化这一项。</li>
</ul>
</li>
<li><p>看橘色部分,使用Jensen不等式:</p>
<ul>
<li><p>这一步推导使用了论文<a href="https://pdfs.semanticscholar.org/f586/4b47b1d848e4426319a8bb28efeeaf55a52a.pdf" rel="external nofollow" target="_blank">《The IM Algorithm : A variational approach to Information Maximization》</a>中的推导公式</p>
<script type="math/tex; mode=display">
I(\mathbf{x}, \mathbf{y}) \geq \underbrace{H(\mathbf{x})}_{\text { ‘‘entrop’’ }}+\underbrace{\langle\log q(\mathbf{x} | \mathbf{y})\rangle_{p(\mathbf{x}, \mathbf{y})}}_{\text { ‘‘energy’’ }} \stackrel{\mathrm{def}}{=} \tilde{I}(\mathbf{x}, \mathbf{y})</script></li>
<li><p><img src="./rl-rough-reading/Agakov.png" alt=""></p>
</li>
<li><p>蓝色公式中,有$I(Z;S) = \mathcal{H}[Z]-\mathcal{H}[Z | S]$,可以应用上述性质进行推导,将真实分布$p(z | s)$替换为任意变分分布(variational distribution)$q(z | s)$</p>
</li>
<li><p>最后使用变分下界$\mathcal{G}(\theta, \phi)$代替目标函数$\mathcal{F}(\theta)$</p>
</li>
</ul>
</li>
<li><p>至此,思路已经十分清晰。Actor网络以变量$\theta$参数化,并使用SAC算法($\alpha=0.1$)最大化$\mathcal{G}(\theta, \phi)$中$\mathcal{H}[A | S, Z]$部分;Critic网络以变量$\phi$参数化,并最大化后半个期望部分。文中将期望内的元素定义为“伪奖励”:</p>
<script type="math/tex; mode=display">
r_{z}(s, a) \triangleq \log q_{\phi}(z | s)-\log p(z)</script><p>由于$p(z)$为均匀分布,是固定的;对数函数不改变原函数单调性,所以只需最大化$q_{\phi}(z | s)$即可。</p>
</li>
</ul>
<h2 id="伪代码-2"><a href="#伪代码-2" class="headerlink" title="伪代码"></a>伪代码</h2><p><img src="./rl-rough-reading/diayn-pseudo.png" alt=""></p>
<p>解析:</p>
<ul>
<li>每个episode都重新采样隐变量$z$</li>
<li>Actor网络的输入为$(S||Z)$,即状态与隐变量的连结(我猜的= =)</li>
<li>Critic网络的输入为状态$S$</li>
</ul>
<h2 id="模型示意图-1"><a href="#模型示意图-1" class="headerlink" title="模型示意图"></a>模型示意图</h2><p><img src="./rl-rough-reading/diayn.png" alt=""></p>
<p>解析:</p>
<ul>
<li>隐变量分布$p(z)$是固定的</li>
</ul>
<h1 align="center" style="color:blue" id="CDP">Curiosity-Driven Experience Prioritization via Density Estimation[CDP]</h1>
论文地址:[https://arxiv.org/pdf/1902.08039.pdf](https://arxiv.org/pdf/1902.08039.pdf)
这篇文章发于2018年的NIPS,作者为赵瑞,之前读过他的两篇论文,并写了博客,可以在论文精读里找,此处不贴链接了,分别是基于能量的HER和最大熵正则化多目标RL。
这篇文章总的来说提出了**基于迹密度的优先经验回放**,人类的好奇心机制驱动他有了这样的想法,文中说受有监督学习使用过采样和降采样解决训练集样本不平衡问题的启发,想在强化学习中解决经验池中迹“不足(under-represented)”的问题。
说起来也挺佩服这个作者的,目前(2019年6月21日14:59:05)总共发了三篇关于强化学习的论文,但都有很好地结果:
1. 基于迹能量的优先级,发了CoRL
2. 基于迹密度的优先级,也就是这篇,发了NIPS
3. 基于迹最大熵的优先级,发了ICML
我个人道行尚浅,对于几篇论文中的深奥精髓有些不能尽数参透,由于先验知识不足,对于文中内容也不敢完全苟同,但是从这几篇阅读总结下来,发得了这种高级别论文有以下几个“加分性”要求:
1. 数学要好,这是必然的,数学公式写的越华丽,数学模型越复杂,当然越具有吸引力
2. 工作要专一且连续,看这三篇论文虽然不是递进关系,但都是在解决经验池优先相关的工作,所以找准一个领域内的小角度也是很重要的
3. 实验部分要做好,三篇都没用完整地、细节地比较各个算法,但是却新奇地比较了采样复杂性、数据利用率等等,总之,一定要用实验表明自己的方法在某方面有用
4. 其他秘密因素
## 流程
这篇论文的方法流程如下:
1. 计算**迹密度**$\rho$
2. 计算迹密度的补$\overline{\rho} \propto 1-\rho$
3. 根据补排序,并设置优先级,补越大优先级越大
4. 使用HER补充经验,设置相同的优先级和迹密度
5. 优化算法
## 迹密度的计算
这一部分没有看太懂,主要是本人数学功底比较薄弱,感兴趣的可以亲自查看论文中2.4与3.2.1、3.2.2部分。
根据文中的意思,思想大致如下:
1. 用GMM(高斯混合模型)来估计迹密度
$$
\rho(\mathbf{x})=\sum_{k=1}^{K} c_{k} \mathcal{N}\left(\mathbf{x} | \boldsymbol{\mu}_{k}, \boldsymbol{\Sigma}_{k}\right)
$$
2. 在每个epoch,使用V-GMM(GMM的一个变体)+EM算法推断GMM参数($\boldsymbol{\mu}_{k}, \boldsymbol{\Sigma}_{k}$)的后验分布
3. 在每个episode,使用如下公式计算迹密度
$$
\rho=\mathrm{V}-\operatorname{GMM}(\mathcal{T})=\sum_{k=1}^{K} c_{k} \mathcal{N}\left(\mathcal{T} | \boldsymbol{\mu}_{k}, \boldsymbol{\Sigma}_{k}\right)
$$
其中,$\mathcal{T}=\left(s_{0}\left\|s_{1}\right\| \ldots \| s_{T}\right)$,**每个迹的长度相同**,中间的符号代表连结操作的意思,然后进行归一化
$$
\rho_{i}=\frac{\rho_{i}}{\sum_{n=1}^{N} \rho_{n}}
$$
*注:我猜想上边符号表示的$s$其实包含了智能体的所在状态和要达到的真实目标,也就是$(s,g)$,文中有一段可能解释了这一部分,但是我没有太理解。*

## 优先级的设定
作者说使用rank-based方法来设置优先级,因为其受异常点影响小而具有良好的鲁棒性。
先计算迹密度的补
$$
\overline{\rho} \propto 1-\rho
$$
将补从小到大排序,并根据排名计算优先级,排名从0开始,即
$$
\operatorname{rank}(\cdot) \in\{0,1, \ldots, N-1\}
$$
$$
p\left(\mathcal{T}_{i}\right)=\frac{\operatorname{rank}\left(\overline{\rho}\left(\mathcal{T}_{i}\right)\right)}{\sum_{n=1}^{N} \operatorname{rank}\left(\left(\overline{\rho}\left(\mathcal{T}_{n}\right)\right)\right.}
$$
## 伪代码

解析:
- 每个epoch根据经验池中的样本数据重新拟合一次密度模型,也就是GMM中的参数
- 每个episode都计算其迹密度
- 红色框中的公式数字编号分别代表之间部分中关于计算迹密度和迹优先级的公式
- 采样迹、采样经验转换之后,需要采样目标并存入经验池,重构后的经验其优先级及迹密度与真正目标下迹的相同
## 优点
实验部分的比较详见论文。
1. 可以适用于任何Off-Policy算法
2. 不使用TD-error计算优先级,而使用迹密度,减少了计算时间
3. 提升了采样效率两倍左右
4. 算法性能超过最新算法9%(这个结果看看即可,不必放在心上)
<h1 align="center" style="color:blue" id="NAF">[Google]Continuous Deep Q-Learning with Model-based Acceleration[NAF]</h1>
论文地址:[https://arxiv.org/abs/1603.00748](https://arxiv.org/abs/1603.00748)
本文介绍了标准化优势函数Normalized Advantage Function——NAF算法,该算法简化了A-C架构,将Q-Learning的思想应用于高维连续空间。
本文的主要贡献是:
1. 提出NAF,简化了Actor-Critic架构
2. 将Q-Learning推广至高维连续空间
3. 提出新的与已学模型结合的方法,提升了采样复杂性(也就是降低)和学习效率,不牺牲策略的最优性。原文中翻译意思是,评估了几种将已学习模型与Q-Learning结合的方案,提出将局部线性模型与局部On-Policy想定推演结合以加速Q-Learning算法在model-free、连续问题下的学习
## 伪代码

解析:
- 待写
<h1 align="center" style="color:blue" id="ERE">[NYU]Boosting Soft Actor-Critic: Emphasizing Recent Experience without Forgetting the Past[ERE]</h1>
<p>论文地址:<a href="http://arxiv.org/abs/1906.04009" rel="external nofollow" target="_blank">http://arxiv.org/abs/1906.04009</a></p>
<p>代码仓库:<a href="https://github.com/BY571/Soft-Actor-Critic-and-Extensions" rel="external nofollow" target="_blank">https://github.com/BY571/Soft-Actor-Critic-and-Extensions</a>(不确定是否为论文原作者的仓库,该仓库PER的实现没有用sum-tree,2020年04月02日13:42:44)</p>
<p>这篇论文主要是对经验池机制的扩展,SAC是被应用的算法。</p>
<p>ERE是Emphasizing Recent Experience的缩写,从名字即可以看出,该经验池机制的侧重点是近期经验。简单说一下ERE的思想及流程:</p>
<ol>
<li>强调近期观测到的数据,同时不遗忘过去学到的知识;</li>
<li>在更新神经网络参数时,比如要连续更新$K$次,即要从经验池中循环取$K$个mini-batch的数据,那么,在第一次更新时,从整个经验池进行采样,后续更新时,逐渐缩小经验池的可采样范围,也就是收缩,使得在间隔内更新的次数也多,近期经验被采样出的概率越大</li>
</ol>
<p>论文中的原句:</p>
<blockquote>
<p>We propose Emphasizing Recent Experience (ERE), a simple but powerful off-policy sampling technique, which emphasizes recently observed data while not forgetting the past. The ERE algorithm samples more aggressively from recent experience, and also orders the updates to ensure that updates from old data do not overwrite updates from new data.</p>
</blockquote>
<h2 id="经验池逐渐缩放的原理"><a href="#经验池逐渐缩放的原理" class="headerlink" title="经验池逐渐缩放的原理"></a>经验池逐渐缩放的原理</h2><p>核心思想是,在训练阶段(也就是先收集好一批轨迹,然后再更新$K$次的阶段),第一个mini-batch数据从整个经验池范围采样,在后续次序的更新中,我们逐渐减小经验池的可采样范围,使得mini-batch数据中包含越来越多的近期经验。</p>
<p>举个例子:假如经验池共十个位置,即0到9,0放置最新的经验,9放置最旧的经验,batch-size为2,那么在第一次更新时,从0-9中采样两条经验。在第二次更新时,从0-8中采样两条经验。……以此类推。</p>
<p>论文中提出了下边这个公式:</p>
<script type="math/tex; mode=display">
c_{k}=\max \left\{N \cdot \eta^{k \frac{1000}{K}}, c_{\min }\right\}</script><p>在这个公式中,$N$代表经验池的总容量;$\eta \in(0,1]$是引入的一个超参数,用来决定<strong>对近期数据的重视程度</strong>,当$\eta=1$时等同于均匀采样,当$\eta<1$时,$c_k$随着更新次数逐渐减小。作者通过实验发现$\eta \in(0.994,0.999)$时效果不错;$c_{min}$是为$c_k$设置的一个下界,防止从一个很小的范围内采样数据,可能会导致过拟合现象。大写的$K$表示更新的册数,小写的$k$,$1\leq k \leq K$,表示当前是第几次更新。</p>
<p>虽然作者说只引入了$\eta$这一个超参数,但其实我觉得,更新次数$K$与基数$1000$也属于可调的超参数,虽然在实验中往往将$K$设置为一条轨迹的步长,即有多少步就更新多少次,这样在更新次数上与一步一更新是一致的,但是说到底它也是个可变的参数。</p>
<p>文中还提到ERE可以与PER相结合,先决定采样区间,再按照区间内经验的权重选择批数据进行更新。通过代码没有看到在ERE与PER结合时使用sum-tree结构,可能在sum-tree结构上ERE不能很好适用,因为区间的选择也会改变树根节点的位置,为各种功能的计算都引入不便。</p>
<script type="math/tex; mode=display">
P(i)=\frac{p_{i}^{\alpha}}{\sum_{j} p_{j}^{\alpha}}, i, j \in D_{c_{k}}</script><p>$D_{c_k}$即为经验池中前$c_k$个近期的经验数据。</p>
<h2 id="伪代码-3"><a href="#伪代码-3" class="headerlink" title="伪代码"></a>伪代码</h2><p><img src="./rl-rough-reading/ere-pseudo.png" alt=""></p>
<h2 id="优缺点"><a href="#优缺点" class="headerlink" title="优缺点"></a>优缺点</h2><p>优点:</p>
<ol>
<li>简单有效</li>
<li>可用于任何使用经验池机制的off-policy算法中,通用性强</li>
<li>引入的额外计算损耗可以忽略不计</li>
<li>只引入一个超参数$\eta$,用来控制经验池可采样范围缩减的速率,容易调节(我觉得公式中的1000以及$c_{min}$应该也算是需要手动设置的超参数)</li>
<li>可以结合PER使用</li>
</ol>
<p>缺点:</p>
<ol>
<li>传统off-policy算法的更新方式是走一步更新一次参数,像baseline等许多仓库都是这么做的,但是OpenAI的Spinning Up仓库却采用先采样一条轨迹,然后按照轨迹的步长为更新次数,循环更新网络。该论文提出的ERE也是使用先采样轨迹再更新的方式,目前看来不能应用在一步一更新的优化方式中,因为各个时间步的经验池是略有不同的</li>
<li>创新很小,实验上也没有看出明显的提升。而且,增加重放近期经验的次数的本质原因也不清楚,似乎只是实验效果不错,所以就这样错了,没有看到比较透彻的数学分析</li>
</ol>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>该论文的实验图见原文。虽然在许多环境中都产生了1.收敛速度更快一点,2.最终性能得分更高一些,但是总感觉不那么make sense。我个人觉得这个ERE可用可不用,它更像是一种实验得出来有效的trick,而不像是为了解决某一问题而特定研究出来的方法。该方法可以当做是扩展眼界的trick。</p>
<h1 align="center" style="color:blue" id="6SAN">Reinforcement Learning with Attention that Works: A Self-Supervised Approach</h1>
<p>论文地址:<a href="http://arxiv.org/abs/1904.03367" rel="external nofollow" target="_blank">http://arxiv.org/abs/1904.03367</a></p>
<p>这篇文章是将self-attention结合进强化学习,并在PPO算法上进行了验证,使用了Arcade Learning Environment的10个环境,分3个随机种子进行实验。</p>
<p>由于论文中没有明确的self-attention在RL中的运算过程,所以目前不太清楚中间的计算细节。</p>
<h2 id="提出的方法"><a href="#提出的方法" class="headerlink" title="提出的方法"></a>提出的方法</h2><p><img src="./rl-rough-reading/6san.png" alt=""></p>
<p>上图为论文提出的Self-Attention在RL中应用的总体架构,其中$H_1,H_2,H_3$均为卷积层。文中将自注意力层加在了卷积层中间,而不是像DARQN一样将注意力层放置在卷积层之后。文中并未对Self-Attention模块中$F_1,F_2,G_1,Y$的运算进行解释。</p>
<p>作者对self-attention的可能实现做了深入的探索,提出并实验了六种结构:</p>
<ol>
<li><p>SAN: Self-Attending Network 在$H_1,H_2$最底层网络间加入自注意力机制</p>
</li>
<li><p>SSAN: Strong Self-Attending Network 意思似乎是将自注意力机制的输出$Y$乘以因子2,以增强注意力在网络中的影响</p>
<blockquote>
<p>Multiplying the output of the last convolutional layer in the self-attention component (’Y’) by a factor of two (thereby increasing the influence of attention on the network).</p>
</blockquote>
</li>
<li><p>SADN: Self-Attending Double Network 加入两个自注意力层,分别在$H_1, H_2$与$H_2, H_3$之间</p>
</li>
<li><p>SSADN: Strong Self-Attending Double Network 两注意力层的输出均乘2</p>
</li>
<li><p>PSAN: Pure Self-Attending Network 只使用注意力层的输出作为特征表示</p>
<blockquote>
<p>Passing only the output of the selfattention forward, removing the addition of the previous convolutional layer output.</p>
</blockquote>
</li>
<li><p>PSADN: Pure Self-Attending Double Network 与上相同</p>
</li>
</ol>
<h2 id="总结-1"><a href="#总结-1" class="headerlink" title="总结"></a>总结</h2><p>实验结果与分析见论文原文。</p>
<p>此篇文章略读思想即可,文章中没有自注意力机制的完整计算流程,也没有开源源代码,因此无法了解到具体细节。而且,文章中提出了六种自注意力机制结构并进行了实验,个人感觉这六种结构不全是必要的,比如SSAN与PSAN这两类的完全没有get到这么设置的意义,给人一种为了做对比试验而设置的感觉。本篇文章创新性也不高。</p>
<h1 align="center" style="color:blue" id="MANet">[SNU]Multi-focus Attention Network for Efficient Deep Reinforcement Learning[MANet]</h1>
<p>论文地址:<a href="http://arxiv.org/abs/1712.04603" rel="external nofollow" target="_blank">http://arxiv.org/abs/1712.04603</a></p>
<p>这篇文章17年发表在AAAI上,提出了MANet算法(多焦点注意力+DQN),它的创新点主要是将图像分割成若干区域,在这些区域中并行计算注意力权重,最终加权得到新的状态特征。作者展示了MANet算法可以应用在<strong>单智能体图像输</strong>入的环境中,也可以扩展模型应用<strong>在多智能体合作任务</strong>中。</p>
<p>作者提出MANet针对的问题是:当前深度强化学习模型无法利用感知数据中实体与实体之间的关系,因此需要大量的采样经验去学习。作者希望通过多焦点注意力模型将感知数据中局部范围内实体之间的关系给embed到状态特征之中,加速策略模型学习并且提升模型性能。</p>
<blockquote>
<p>current DRL models connect the entire low-level sensory input to the state-action values rather than exploiting the relationship between and among entities that constitute the sensory input.</p>
</blockquote>
<p>最终实验结果简报是:</p>
<ol>
<li>与DQN做比较时,单智能体场景中使用更少经验取得最高得分</li>
<li>在多智能体合作任务中,相较于SOTA算法(18年以前),MANet加速学习20%</li>
</ol>
<blockquote>
<p>MANet attains highest scores with significantly less experience samples. Additionally, the model shows higher performance compared to the Deep Q-network and the single attention model as benchmarks. Furthermore, we extend our model to attentive communication model for performing multi-agent cooperative tasks. In multi-agent cooperative task experiments, our model shows 20% faster learning than existing state-of-the-art model.</p>
</blockquote>
<h2 id="模型讲解"><a href="#模型讲解" class="headerlink" title="模型讲解"></a>模型讲解</h2><p><img src="./rl-rough-reading/MANet-structure.png" alt=""></p>
<p>上图为论文中提出的MANet的结构示意图。MANet主要由四个模块组成:</p>
<ul>
<li>输入分割模块(Input Segmentation)</li>
<li>特征提取模块(Feature Extraction)</li>
<li>并行注意力模块(Parallel Attentions)</li>
<li>状态-动作值估计模块(State-action Value Estimation)</li>
</ul>
<p><strong>在单智能体任务中</strong>:</p>
<ol>
<li><p>输入分割模块</p>
<p>在这个阶段主要将底层传感器输入分割成多个块/区域,将每一个块的状态称为局部状态。作者使用了最简单的均匀格子切分方法,就是每个局部状态格子大小相同。作者也提到可以使用其他分割方式,可能由于实现困难或者切分后图像大小不一致使处理困难等因素而没有采用。</p>
<blockquote>
<p>We believe that we can apply more sophisticated methods like super-pixel segmentation (Achanta et al. 2010) or spatial transformer networks (Jaderberg, Simonyan, and Zisserman 2015).</p>
</blockquote>
</li>
<li><p>特征提取模块</p>
<p>这个模块主要从每个局部状态提取键(Key)特征和值(Value)特征。</p>
<p>其中,键特征主要用于决定模型应该注意到的位置</p>
<blockquote>
<p>The key features are used to determine where the model should attend.</p>
</blockquote>
<p>值特征主要用于编码用于评估Q值的信息</p>
<blockquote>
<p>The value features are used to encode information for state-action value estimation.</p>
</blockquote>
<p>这一模块的计算过程是这样的,首先提取局部状态的通用特征:</p>
<script type="math/tex; mode=display">
c_{i}=f_{f}\left(s_{i}\right) \text { for all } i \in(0,1, \ldots, K)</script><p>其中,$K$为第一阶段切分的局部状态的个数,$s_i$表示第$i$个局部状态,$c_i$表示其通用特征,$f_f$是特征提取函数(作者使用深度卷积网络)。</p>
<p>然后,将通用特征$c_i$与局部状态的索引$i$拼接后,再计算键特征与值特征:</p>
<script type="math/tex; mode=display">
\begin{aligned}
&K e y_{i}=W_{k e y} * c_{i}\\
&V a l_{i}=f_{v}\left(W_{v a l} * c_{i}\right)
\end{aligned}</script><p>其中,$Key_i$与$Val_i$分别表示第$i$个局部状态的键、值特征。$f_v$表示非线性激活函数(作者使用的是leaky ReLU),$W_{key},W_{val}$是权重矩阵。</p>
</li>
<li><p>并行注意力模块</p>
<p>这一模块主要是区分各个局部状态的重要性,按重要性的不同加权表示特征。</p>
<script type="math/tex; mode=display">
A_{i}^{n}=\frac{\exp \left(a_{n} * Key_{i}^{T}\right)}{\sum_{i^{\prime}} \exp \left(a_{n^{*} Key_{i^{\prime}}^{T}}\right)} \text { for all } n \in(0,1, \ldots, N)</script><p>其中,$N$是上面结构图中注意力层的数量,$A_i^n$表示第$n$层注意力的向量的第$i$个元素,$i^{\prime} \in\{0,1, \ldots, \mathrm{K}\}$,$a_n$是第$n$个选择向量(图中的selector,像神经网络参数一样可以被训练)。上述公式其实是softmax的形式。</p>
<p>由于$a$的随机初始化基本上相似,所以计算得来的注意力权重也必将相近,作者不希望所有的注意力层都注意某一局部区域(或者相似区域),比如说第5个局部区域,这样的话就很低效。作者希望多个注意力层可以皆可能地注意到不同的局部状态,以达到多焦点(multi-focus)的效果,作者探索了两种正则化方式来鼓励这种行为。</p>
<p>第一种正则化方法是熵正则化:</p>
<script type="math/tex; mode=display">
R_{e}=\lambda_{e} * \sum_{n}\left\|A^{n} * \log A^{n}\right\|</script><p>这个式子的熵的负数形式,值越小,越随机(越雨露均沾),趋向于均匀分布,也就是越不集中注意力。</p>
<p>第二种正则化方法是距离正则化:</p>
<script type="math/tex; mode=display">
R_{d}=\lambda_{d} * \exp \left(-\sum_{n, m}\left(A^{n}-A^{m}\right)^{2}\right)</script><p>这个式子为$e$的指数性质,值越小,说明两个注意力层注意关注的区域越不相同,也就是越集中注意力且注意不同的局部状态。</p>
<p><em>由于论文没有开源源代码,所以目前不确定熵正则化项的具体应用方式,不知道是最大化熵正则化项以鼓励不同注意力层注意不同区域,还是最小化熵正则化项以trade-off距离正则化项,放置距离正则化项过多的注意不同区域。</em></p>
</li>
<li><p>状态-动作值估计模块</p>
<p>这一模块综合每个注意力层的输出特征,并且输入到剩余网络以估计状态-动作值。作者将基于注意力的加权值特征定义为:</p>
<script type="math/tex; mode=display">
h_{n}=\sum_{i} V a l_{i} * A_{i}^{n}</script><p>其中,$h_n$是由第$n$个注意力层的注意力权重$A^n$加权的值特征。最终联合特征和Q值表示为:</p>
<script type="math/tex; mode=display">
g=\left\{h_{0}, h_{1}, \ldots, h_{N}\right\}</script><script type="math/tex; mode=display">
Q=f_{q}(g)</script></li>
</ol>
<p><strong>在多智能体合作任务中</strong>:</p>
<p> 在这种任务中,MANet主要将其它智能体的相关信息加权到某个智能体的状态特征中,相当于特征融合。</p>
<ol>
<li><p>输入分割模块</p>
<p>每一个智能体即是局部状态,因此不用分割,故不需要该模块。</p>
</li>
<li><p>特征提取模块</p>
<script type="math/tex; mode=display">
\begin{aligned}
&c_{i}=f_{f}\left(s_{i}\right) \text { for all } i \in(0,1, \ldots, K)\\
&K e y_{i}=W_{k e y} * c_{i}\\
&\color{red}{a_{i}=W_{a} * c_{i}}\\
&V a l_{i}=f_{v}\left(W_{v a l} * c_{i}\right)
\end{aligned}</script><p>$K$表示任务中智能体的个数。与单智能体不同的是,这里的selector是由通用特征$c_i$与权重矩阵$W_a$计算得来的,如上述公式红色字体所示。</p>
</li>
<li><p>注意力交流模块(Attentive Communication)</p>
<script type="math/tex; mode=display">
A_{j}^{i}=\frac{\exp \left(a^{i} * \operatorname{Key}_{j}^{T}\right)}{\sum_{j^{\prime}} \exp \left(a^{i} * \operatorname{Ke} y_{j^{\prime}}^{T}\right)} \quad i, j \in(0,1, \ldots, K)</script><p>$A_j^i$表示智能体$j$对智能体$i$的注意力权重,值越大则$j$的信息对$i$越重要。</p>
</li>
<li><p>状态-动作值估计模块</p>
<script type="math/tex; mode=display">
\begin{array}{c}
h_{i}=\sum_{j} V a l_{j} * A_{j}^{i} \quad j \in(0,1, \ldots, K) \\
g_{i}=\left\{V a l_{i}, h_{i}\right\} \\
Q_{i}=f\left(g_{i}\right)
\end{array}</script><p>$h_i$为第$i$个智能体的交流特征——从其他智能体的特征中基于注意力加权得来的。</p>
<p>在多智能体任务中,由于selector $a$与智能体的通用特征相关,因此之间不太相似,所以不需要熵和距离正则化项(作者认为的)。</p>
<p>作者添加了另一个正则化项$R=\lambda \cdot \left(a \cdot Key^{T} \right)$以解决值容易发散的问题。<strong><em>我目前还没有理解到这个正则化项的作用及意义。</em></strong></p>
</li>
</ol>
</div>
<div>
<div>
<div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-heart"></i>感谢您的阅读-------------</div>
</div>
</div>
<div>
<div class="my_post_copyright">
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
<!-- JS库 sweetalert 可修改路径 -->
<script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>