-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCS 285 Lecture 2, Part 1.srt
2072 lines (1567 loc) · 38.8 KB
/
CS 285 Lecture 2, Part 1.srt
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
1
00:00:00,719 --> 00:00:05,175
hello and welcome to the second lecture
of cs285
2
00:00:05,200 --> 00:00:09,175
today we're going to talk about
supervised learning of behaviors
3
00:00:09,200 --> 00:00:13,095
so let's start with a little bit of
terminology and notation
4
00:00:13,120 --> 00:00:16,631
if we have a regular supervised learning
problem
5
00:00:16,656 --> 00:00:20,215
let's say a computer vision problem an
object recognition problem
6
00:00:20,240 --> 00:00:22,986
we might want to recognize objects in an image
7
00:00:23,011 --> 00:00:24,694
so we might have some input image
8
00:00:24,719 --> 00:00:27,014
that goes through a deep neural network
9
00:00:27,039 --> 00:00:29,174
and the output is a label
10
00:00:29,199 --> 00:00:35,148
so the terminology we're going to use
here is going to be kind of reinforcement learning terminology
11
00:00:35,173 --> 00:00:37,123
and i'll gradually
work from
12
00:00:37,148 --> 00:00:41,906
using reinforcement terminology from us
for a standard supervised learning example
13
00:00:41,931 --> 00:00:45,964
to then turn that into a reinforcement
learning problem
14
00:00:45,989 --> 00:00:49,895
so we're going to call the input o for
observation
15
00:00:49,920 --> 00:00:52,328
and we're going to call the output a for action
16
00:00:52,353 --> 00:00:55,975
but for now the input is an image
and the output is a label
17
00:00:56,000 --> 00:01:00,191
the neural network in the middle or in general
whatever kind of model you might want to have
18
00:01:00,216 --> 00:01:04,557
that maps the observations to actions
we're going to call policy
19
00:01:04,582 --> 00:01:07,575
and we'll denote it with the the
letter pi
20
00:01:07,600 --> 00:01:11,833
where the subscript theta represents the
parameters of that policy
21
00:01:11,858 --> 00:01:15,783
so in a neural net
theta represents the weights of that neural net
22
00:01:15,808 --> 00:01:26,375
so we have an input o an output a and a mapping between them
pi subscript theta which gives a distribution over a given o
23
00:01:26,400 --> 00:01:30,454
now in reinforcement learning of course
we're concerned with
24
00:01:30,479 --> 00:01:32,656
sequential decision making problems
25
00:01:32,681 --> 00:01:36,969
so all of these inputs and outputs
occur at some point in time
26
00:01:37,038 --> 00:01:41,991
so we'll typically use a subscript
t to denote the time step at which they happen
27
00:01:42,016 --> 00:01:45,549
usually in reinforcement learning
we deal with discrete time problems
28
00:01:45,574 --> 00:01:49,749
so we assume that
time is broken up into little discrete steps
29
00:01:49,774 --> 00:01:53,860
and t is an integer that
represents at which step do you observe o
30
00:01:53,885 --> 00:01:56,593
and at which step do you emit a
31
00:01:56,618 --> 00:02:02,879
so now pi theta gives a
distribution over a t conditional ot
32
00:02:02,880 --> 00:02:05,454
and of course unlike regular supervised learning
33
00:02:05,479 --> 00:02:10,965
in reinforcement learning the output
at one time step influences the input at the next
34
00:02:10,990 --> 00:02:15,434
so a t has an effect on ot plus one
35
00:02:15,459 --> 00:02:20,559
so if you for example fail to recognize
the tiger then at the next time step
36
00:02:20,560 --> 00:02:26,399
you might see something undesirable like
maybe the tiger will be a lot closer to you
37
00:02:26,400 --> 00:02:32,615
so you could extend this basic idea
to learn policies
38
00:02:32,640 --> 00:02:37,119
for control so obviously instead of outputting
labels you would probably output something
39
00:02:37,120 --> 00:02:42,895
that looks a lot more like an action but it
could still be a discrete action it could still use a soft max distribution
40
00:02:42,920 --> 00:02:47,748
so for instance
you could choose from a discrete set of options upon seeing the tiger
41
00:02:47,773 --> 00:02:50,214
but you could also
have a continuous action
42
00:02:50,239 --> 00:02:55,520
in which case pi theta outputs the
parameters of some continuous distribution
43
00:02:55,545 --> 00:03:01,598
such as the mean and variance of a
multivariate normal or gaussian distribution
44
00:03:01,599 --> 00:03:06,535
so to summarize the terminology ot
represents the observation
45
00:03:06,560 --> 00:03:09,333
a t represents the action
46
00:03:09,358 --> 00:03:16,294
and then pi subscript theta a t given ot
is the policy
47
00:03:16,319 --> 00:03:21,095
now another term that we'll see a lot in
reinforcement learning
48
00:03:21,120 --> 00:03:25,574
is the state which we'll denote as st
49
00:03:25,599 --> 00:03:31,107
and sometimes we'll see the policy
written as a t given st
50
00:03:31,132 --> 00:03:33,920
the difference between st and ot
51
00:03:33,945 --> 00:03:39,679
is that the state is typically assumed to be
a markovian state which i'll explain shortly
52
00:03:39,680 --> 00:03:44,055
whereas ot is an observation that
results from that state
53
00:03:44,080 --> 00:03:48,158
so most generally we would write a
policy as being conditional and observation
54
00:03:48,159 --> 00:03:53,425
but sometimes we'll write it as being conditional and
state and that is a more restrictive special case
55
00:03:53,450 --> 00:03:59,280
so let me explain the distinction
between states and observations
56
00:03:59,360 --> 00:04:04,428
let's say that you observe this scene
there is a cheetah chasing a gazelle
57
00:04:04,453 --> 00:04:09,919
now this observation consists of an
image and the image is made of pixels
58
00:04:09,920 --> 00:04:15,015
those pixels might be sufficient to figure
out where the cheetah and the gazelle are
59
00:04:15,040 --> 00:04:16,573
or they might not be
60
00:04:16,598 --> 00:04:22,279
but the image is produced
by some underlying physics of some system
61
00:04:22,304 --> 00:04:26,159
and that system has a state it has
a kind of a minimal representation
62
00:04:26,160 --> 00:04:28,706
so the image is the observation ot
63
00:04:28,731 --> 00:04:34,212
the state is the representation of
the current configuration of the system
64
00:04:34,237 --> 00:04:38,948
which in this case might be for instance the position
of the cheetah and the position of the gazelle
65
00:04:38,973 --> 00:04:42,493
and maybe their velocities
66
00:04:42,518 --> 00:04:46,239
now the observation might be altered in
some way
67
00:04:46,264 --> 00:04:51,520
so the full state cannot be inferred
exactly for instance if a car
68
00:04:49,600 --> 00:04:53,199
drives in front of the cheetah and you
69
00:04:51,520 --> 00:04:54,880
can't see it
70
00:04:53,199 --> 00:04:56,880
the observation might be insufficient to
71
00:04:54,880 --> 00:04:58,320
deduce the state
72
00:04:56,880 --> 00:05:00,160
but the state hasn't actually changed
73
00:04:58,320 --> 00:05:01,759
the cheat is still where it was before
74
00:05:00,160 --> 00:05:03,680
is just that now the image pixels and
75
00:05:01,759 --> 00:05:05,840
the observation are not enough
76
00:05:03,680 --> 00:05:07,199
to figure out where it is and that
77
00:05:05,840 --> 00:05:08,720
really
78
00:05:07,199 --> 00:05:10,560
gets at the difference between states
79
00:05:08,720 --> 00:05:12,639
and observations states
80
00:05:10,560 --> 00:05:14,000
are the true configuration of the system
81
00:05:12,639 --> 00:05:15,360
an observation
82
00:05:14,000 --> 00:05:17,840
is something that results from that
83
00:05:15,360 --> 00:05:21,680
state which may or may not be enough
84
00:05:17,840 --> 00:05:23,360
to deduce the state more formally
85
00:05:21,680 --> 00:05:24,960
we can explain the distinction between
86
00:05:23,360 --> 00:05:27,199
states and observations
87
00:05:24,960 --> 00:05:28,720
by using the terminology of graphical
88
00:05:27,199 --> 00:05:31,360
models
89
00:05:28,720 --> 00:05:33,039
so we can draw a graphical model that
90
00:05:31,360 --> 00:05:36,080
represents the relationship
91
00:05:33,039 --> 00:05:38,800
between states and actions and
92
00:05:36,080 --> 00:05:40,240
observations as i mentioned observations
93
00:05:38,800 --> 00:05:42,479
result from states
94
00:05:40,240 --> 00:05:44,000
so there's an arrow from s to o at every
95
00:05:42,479 --> 00:05:46,479
time step
96
00:05:44,000 --> 00:05:48,160
your policy uses the observations to
97
00:05:46,479 --> 00:05:49,680
choose the action so that's the arrow
98
00:05:48,160 --> 00:05:51,280
from o to a
99
00:05:49,680 --> 00:05:53,199
and the state in action at the current
100
00:05:51,280 --> 00:05:55,520
time step determines the state of the
101
00:05:53,199 --> 00:05:58,319
next time step so s1 and a1
102
00:05:55,520 --> 00:05:58,319
go to s2
103
00:05:58,639 --> 00:06:04,560
now from inspecting this graphical model
104
00:06:02,319 --> 00:06:05,759
we might conclude that there are certain
105
00:06:04,560 --> 00:06:09,280
independencies
106
00:06:05,759 --> 00:06:11,759
that are present in the system so
107
00:06:09,280 --> 00:06:13,840
this is the policy pi this is the
108
00:06:11,759 --> 00:06:14,639
transition probabilities p of s d plus
109
00:06:13,840 --> 00:06:18,479
one given s t
110
00:06:14,639 --> 00:06:21,840
a t and something we might note here
111
00:06:18,479 --> 00:06:21,840
is that
112
00:06:22,000 --> 00:06:28,960
p of s t plus 1 given s t 18
113
00:06:25,600 --> 00:06:30,080
is independent of s t minus 1. so for a
114
00:06:28,960 --> 00:06:32,639
state
115
00:06:30,080 --> 00:06:34,160
if you know the current state then you
116
00:06:32,639 --> 00:06:35,440
can figure out the distribution over the
117
00:06:34,160 --> 00:06:37,440
next state
118
00:06:35,440 --> 00:06:39,039
without any regard for the previous
119
00:06:37,440 --> 00:06:41,600
state
120
00:06:39,039 --> 00:06:43,520
that is to say the future is
121
00:06:41,600 --> 00:06:46,080
conditionally independent of the past
122
00:06:43,520 --> 00:06:47,840
given the present this is a very
123
00:06:46,080 --> 00:06:49,919
important independence property
124
00:06:47,840 --> 00:06:51,520
because it says that if you want to make
125
00:06:49,919 --> 00:06:54,560
a decision
126
00:06:51,520 --> 00:06:56,479
that will impact future states
127
00:06:54,560 --> 00:06:57,919
you do not have to consider how you
128
00:06:56,479 --> 00:06:59,280
reach the state you're currently in it's
129
00:06:57,919 --> 00:07:01,120
enough to just consider your current
130
00:06:59,280 --> 00:07:01,599
state and you can forget about previous
131
00:07:01,120 --> 00:07:04,960
states
132
00:07:01,599 --> 00:07:07,199
that led you to it this is called the
133
00:07:04,960 --> 00:07:08,880
markov property and the markov property
134
00:07:07,199 --> 00:07:10,479
is a very very important property in
135
00:07:08,880 --> 00:07:11,759
reinforcement learning and sequential
136
00:07:10,479 --> 00:07:13,759
decision making
137
00:07:11,759 --> 00:07:15,199
because without the markov property we
138
00:07:13,759 --> 00:07:16,880
would not be able to formulate
139
00:07:15,199 --> 00:07:19,520
optimal policies without considering
140
00:07:16,880 --> 00:07:22,240
entire histories
141
00:07:19,520 --> 00:07:24,160
however if our policy is conditioned on
142
00:07:22,240 --> 00:07:27,039
observations rather than states
143
00:07:24,160 --> 00:07:27,680
as it is in this picture we could ask
144
00:07:27,039 --> 00:07:30,160
well
145
00:07:27,680 --> 00:07:31,919
are the observations also conditionally
146
00:07:30,160 --> 00:07:34,160
independent in this way
147
00:07:31,919 --> 00:07:35,360
is the current observation entirely
148
00:07:34,160 --> 00:07:37,039
sufficient
149
00:07:35,360 --> 00:07:39,599
to figure out how to act so as to reach
150
00:07:37,039 --> 00:07:40,800
some state in the future
151
00:07:39,599 --> 00:07:42,319
take a moment to think about this
152
00:07:40,800 --> 00:07:45,840
question and consider writing your
153
00:07:42,319 --> 00:07:45,840
answer in the comments
154
00:07:47,039 --> 00:07:50,160
the trouble is that the observation is
155
00:07:48,639 --> 00:07:52,160
in general not
156
00:07:50,160 --> 00:07:54,000
going to satisfy the markov property
157
00:07:52,160 --> 00:07:55,520
meaning that the current observation
158
00:07:54,000 --> 00:07:57,440
might not be enough to fully determine
159
00:07:55,520 --> 00:07:58,319
the future without also observing the
160
00:07:57,440 --> 00:08:00,479
past
161
00:07:58,319 --> 00:08:02,319
and this is perhaps most obvious from
162
00:08:00,479 --> 00:08:04,479
the example with the cheetah
163
00:08:02,319 --> 00:08:05,759
when the car is in front of the cheetah
164
00:08:04,479 --> 00:08:07,120
and you cannot see where it is in the
165
00:08:05,759 --> 00:08:08,240
image
166
00:08:07,120 --> 00:08:09,759
you might not be able to figure out
167
00:08:08,240 --> 00:08:11,680
where it's going to go in the future
168
00:08:09,759 --> 00:08:14,319
because you can't see it right now
169
00:08:11,680 --> 00:08:16,000
but if in the previous point in time you
170
00:08:14,319 --> 00:08:17,280
could see if maybe the car was somewhere
171
00:08:16,000 --> 00:08:19,039
else before
172
00:08:17,280 --> 00:08:20,400
you could memorize where the cheetah was
173
00:08:19,039 --> 00:08:22,319
so that even when it's occluded by the
174
00:08:20,400 --> 00:08:23,520
car you still remember its state
175
00:08:22,319 --> 00:08:26,000
so in general if you're using
176
00:08:23,520 --> 00:08:27,919
observations past observations can
177
00:08:26,000 --> 00:08:28,960
actually give you additional information
178
00:08:27,919 --> 00:08:30,160
beyond what you would get from the
179
00:08:28,960 --> 00:08:32,399
current observation
180
00:08:30,160 --> 00:08:34,320
that would be useful for decision making
181
00:08:32,399 --> 00:08:36,080
whereas if you directly observe states
182
00:08:34,320 --> 00:08:37,519
then the current state is always going
183
00:08:36,080 --> 00:08:41,120
to give you everything you need
184
00:08:37,519 --> 00:08:42,479
because it satisfies the markov property
185
00:08:41,120 --> 00:08:43,839
now many reinforcement learning
186
00:08:42,479 --> 00:08:44,560
algorithms that we'll discuss in this
187
00:08:43,839 --> 00:08:47,680
course
188
00:08:44,560 --> 00:08:50,399
will actually require markovian
189
00:08:47,680 --> 00:08:51,760
states in which case i will write pi of
190
00:08:50,399 --> 00:08:53,920
a given s
191
00:08:51,760 --> 00:08:55,440
but in some cases i will also mention
192
00:08:53,920 --> 00:08:57,360
that a particular algorithm
193
00:08:55,440 --> 00:08:59,200
could be modified in some way to handle
194
00:08:57,360 --> 00:09:00,640
non-markovian observations
195
00:08:59,200 --> 00:09:02,800
and then i'll describe how that can be
196
00:09:00,640 --> 00:09:02,800
done
197
00:09:03,920 --> 00:09:08,720
now a little aside on notation in
198
00:09:06,800 --> 00:09:11,680
reinforcement learning we typically use
199
00:09:08,720 --> 00:09:13,120
s to denote state and a to denote action
200
00:09:11,680 --> 00:09:14,560
that's very reasonable because those are
201
00:09:13,120 --> 00:09:15,360
the first letters of those words in
202
00:09:14,560 --> 00:09:18,640
english
203
00:09:15,360 --> 00:09:20,240
this kind of terminology was
204
00:09:18,640 --> 00:09:22,320
widely popularized by the study of
205
00:09:20,240 --> 00:09:23,360
dynamic programming which in many ways
206
00:09:22,320 --> 00:09:25,279
was
207
00:09:23,360 --> 00:09:27,040
kind of pioneered by richard bellman in
208
00:09:25,279 --> 00:09:29,200
the 1950s
209
00:09:27,040 --> 00:09:31,440
if you have a background in robotics and
210
00:09:29,200 --> 00:09:32,800
optimal control and linear systems
211
00:09:31,440 --> 00:09:34,480
then you might be more familiar with a
212
00:09:32,800 --> 00:09:36,959
different notation where
213
00:09:34,480 --> 00:09:38,560
x is used to denote state and u is used
214
00:09:36,959 --> 00:09:41,680
to denote action
215
00:09:38,560 --> 00:09:43,200
this is exactly equivalent terminology x
216
00:09:41,680 --> 00:09:45,760
makes sense for state because
217
00:09:43,200 --> 00:09:47,760
that's usually the variable used for an
218
00:09:45,760 --> 00:09:50,000
unknown quantity in algebra
219
00:09:47,760 --> 00:09:52,240
and u is the first word for action in
220
00:09:50,000 --> 00:09:54,480
russian which is
221
00:09:52,240 --> 00:09:55,680
and uh this makes sense because this
222
00:09:54,480 --> 00:09:58,480
kind of terminology
223
00:09:55,680 --> 00:09:59,519
was actually popularized by folks like
224
00:09:58,480 --> 00:10:01,760
left panteragan
225
00:09:59,519 --> 00:10:05,279
who studied optimal control in the
226
00:10:01,760 --> 00:10:07,680
soviet union
227
00:10:05,279 --> 00:10:08,800
all right so that's a little bit of
228
00:10:07,680 --> 00:10:11,360
terminology
229
00:10:08,800 --> 00:10:12,240
but let's talk now about how we can
230
00:10:11,360 --> 00:10:14,560
actually learn
231
00:10:12,240 --> 00:10:16,079
policies and in today's lecture we'll
232
00:10:14,560 --> 00:10:17,440
actually start with a very simple way of
233
00:10:16,079 --> 00:10:19,120
learning policies
234
00:10:17,440 --> 00:10:20,640
that doesn't even require using very
235
00:10:19,120 --> 00:10:21,600
sophisticated reinforcement learning
236
00:10:20,640 --> 00:10:23,760
algorithms
237
00:10:21,600 --> 00:10:25,360
but instead learns policies in much the