{"id":296837,"date":"2020-01-07T15:00:15","date_gmt":"2020-01-07T15:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296837"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296837","title":{"rendered":"Deep Reinforcement Learning: \u043a\u0430\u043a \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043f\u0430\u0443\u043a\u043e\u0432 \u0445\u043e\u0434\u0438\u0442\u044c"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483078\/\">\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/rxWmEnWR3jw?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0433\u043b\u0443\u0431\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u0434\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c. \u0412\u043a\u0440\u0430\u0442\u0446\u0435, \u043f\u043e\u0432\u0435\u0434\u0430\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u00ab\u0447\u0451\u0440\u043d\u044b\u0439 \u044f\u0449\u0438\u043a \u0441 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044f\u043c\u0438\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0440\u043e\u0431\u043e\u0442\u0430, \u0430 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0432\u044b\u0434\u0430\u0451\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c <b>Advantage Actor Critic<\/b> (A2C) \u0441 \u043e\u0446\u0435\u043d\u043a\u043e\u0439 Advantage \u0447\u0435\u0440\u0435\u0437 <b>Generalized Advantage Estimation<\/b> (GAE).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 TensorFlow \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0435\u043c\u043e\u043a \u0442\u043e\u0433\u043e, \u043a \u043a\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c \u0445\u043e\u0434\u044c\u0431\u044b \u0441\u043e\u0448\u043b\u0438\u0441\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/p>\n<p>   \u2014 <a href=\"#problem\">\u0417\u0430\u0434\u0430\u0447\u0430<\/a><br \/>   \u2014 <a href=\"#why-rl\">\u041f\u043e\u0447\u0435\u043c\u0443 Reinforcement Learning?<\/a><br \/>   \u2014 <a href=\"#rl-formulation\">\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 Reinforcement Learning<\/a><br \/>   \u2014 <a href=\"#policy-gradient\">Policy gradient<\/a><br \/>   \u2014 <a href=\"#diagonal-gaussian-policies\">Diagonal Gaussian Policies<\/a><br \/>   \u2014 <a href=\"#add-critic\">\u0423\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c variance \u043f\u0443\u0442\u0451\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430<\/a><br \/>   \u2014 <a href=\"#pitfalls\">\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/a>  <\/p>\n<p> \u2014 <a href=\"#conclusion\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/a><\/p>\n<p>  <a name=\"problem\"><\/a><\/p>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u043c \u0443\u0447\u0438\u0442\u044c \u0440\u043e\u0431\u043e\u0442\u0430 \u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438 MuJoCo. \u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0448\u0430\u0433\u0430 \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u043e\u0431\u043e\u0442\u0430 \u0438 Python \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043a \u0441\u0440\u0435\u0434\u0435, \u0442.\u043a. \u0442\u0430\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u043d\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0434\u0435\u043c\u043a\u0438 \u0432 \u0441\u0430\u043c\u043e\u0439 MuJoCo \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 MuJoCo-\u0441\u0440\u0435\u0434 \u0432 <a href=\"https:\/\/gym.openai.com\/envs\/#mujoco\" rel=\"nofollow\">Gym OpenAI<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0443 \u0430\u0433\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u0438\u0437 MuJoCo: \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0443\u0433\u043b\u044b \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u0435\u0439 \u0442\u0435\u043b\u0430 \u0440\u043e\u0431\u043e\u0442\u0430, \u0438 \u0442.\u0434. \u0412 \u0441\u0443\u043c\u043c\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 ~800 \u0444\u0438\u0447\u0435\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Deep Learning \u043f\u043e\u0434\u0445\u043e\u0434 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442. \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0447\u0438\u0441\u0435\u043b \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0430\u0433\u0435\u043d\u0442 \u043c\u043e\u0433 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u0442\u044c 18 \u0447\u0438\u0441\u0435\u043b \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0435\u043f\u0435\u043d\u0435\u0439 \u0441\u0432\u043e\u0431\u043e\u0434\u044b \u0440\u043e\u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0443\u0433\u043b\u044b \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0448\u0430\u0440\u043d\u0438\u0440\u043e\u0432, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u044b \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0446\u0435\u043b\u044c\u044e \u0430\u0433\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443 (<b>reward<\/b>) \u0437\u0430 \u044d\u043f\u0438\u0437\u043e\u0434. \u0411\u0443\u0434\u0435\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u044d\u043f\u0438\u0437\u043e\u0434, \u0435\u0441\u043b\u0438 \u0440\u043e\u0431\u043e\u0442 \u0443\u043f\u0430\u043b \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0448\u043b\u043e 3000 \u0448\u0430\u0433\u043e\u0432 (15 \u0441\u0435\u043a\u0443\u043d\u0434). \u041a\u0430\u0436\u0434\u044b\u0439 \u0448\u0430\u0433 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0430\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u0430 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8d3\/6cb\/a20\/8d36cba20a1783b20fdc5b9ef372e515.svg\" alt=\"$\\newcommand{\\E}{\\mathop{\\mathbb{E}}}\\newcommand{\\R}{\\mathop{\\mathbb{R}}}r_t = \\Delta x * 1000 + 0.5$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0422.\u0435. \u0446\u0435\u043b\u044c\u044e \u0430\u0433\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/817\/b92\/407\/817b92407f764f57af9226e50cc788fd.svg\" alt=\"$x$\" data-tex=\"inline\"><\/math> \u0438 \u043d\u0435 \u043f\u0430\u0434\u0430\u0442\u044c \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u044d\u043f\u0438\u0437\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430: <b>\u043d\u0430\u0439\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/58b\/1fa\/2db\/58b1fa2db2666c108358f79dd43a632b.svg\" alt=\"$\\pi:\\R^{800}\\to\\R^{18}$\" data-tex=\"inline\"><\/math>, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0437\u0430 \u044d\u043f\u0438\u0437\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439<\/b>. \u0417\u0432\u0443\u0447\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c, \u043f\u0440\u0430\u0432\u0434\u0430? \ud83d\ude42 \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0441 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f <b>Deep Reinforcement Learning<\/b>.<\/p>\n<p>  <a name=\"why-rl\"><\/a><\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 Reinforcement Learning?<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0445\u043e\u0434\u044f\u0447\u0438\u0445 \u0440\u043e\u0431\u043e\u0442\u043e\u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a \u0440\u043e\u0431\u043e\u0442\u043e\u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 <b>optimal control<\/b> \u0438 <b>trajectory optimization<\/b>: LQR, QP, \u0432\u044b\u043f\u0443\u043a\u043b\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435: <a href=\"https:\/\/dspace.mit.edu\/handle\/1721.1\/110533\" rel=\"nofollow\">\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0442\u0438\u0432\u0430 Boston Dynamics \u043e \u0440\u043e\u0431\u043e\u0442\u0435 Atlas<\/a>.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u00ab\u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0438\u043d\u0433\u043e\u043c\u00bb, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0412 \u043d\u0438\u0445 \u043d\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c \u2014 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u00ab\u043d\u0430 \u043c\u0435\u0441\u0442\u0435\u00bb.<\/p>\n<p>  <\/p>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, Reinforcement Learning (\u0434\u0430\u043b\u0435\u0435 RL) \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437 \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0434\u0435\u043b\u0430\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u043c \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u043c.<\/p>\n<p>  <a name=\"rl-formulation\"><\/a><\/p>\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 Reinforcement Learning<\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/i8\/gl\/yf\/i8glyfujascwmexl2qu6sypmpt0.png\">  <\/p>\n<p><a href=\"https:\/\/simple.wikipedia.org\/wiki\/Reinforcement_learning\" rel=\"nofollow\"><i>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/i><\/a><\/p>\n<p>  <\/p>\n<p>\u0412 \u0437\u0430\u0434\u0430\u0447\u0435 RL \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430 \u0438 \u0441\u0440\u0435\u0434\u044b \u043a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0430\u0440 <b>(state, reward)<\/b> \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u2014 <b>action<\/b>.<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/606\/5b9\/2d9\/6065b92d9c32c32bb35d8d0ae8773879.svg\" alt=\"$(s_0)\\xrightarrow{a_0}(s_1,r_1)\\xrightarrow{a_{1}}...\\xrightarrow{a_{n-1}}(s_n,r_n)$\" data-tex=\"display\"><\/math><\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044e:<\/p>\n<p>  <\/p>\n<ul>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/be2\/08b\/191\/be208b1910cd4cd6d2bd1dd4a46f560f.svg\" alt=\"$\\pi(a_t|s_t)$\" data-tex=\"inline\"><\/math> \u2014 <b>policy<\/b>, \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0430\u0433\u0435\u043d\u0442\u0430, \u0443\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c,<\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/215\/e63\/228\/215e632280b630da4a34d676ef3b57e6.svg\" alt=\"$a_t\\sim\\pi(\\cdot|s_t)$\" data-tex=\"inline\"><\/math> \u2014 <b>action<\/b> \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u043a\u0430\u043a \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7af\/18b\/081\/7af18b0819e3a7a12aadc52f24feb01f.svg\" alt=\"$\\pi$\" data-tex=\"inline\"><\/math>, <br \/>   <i>\u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c policy \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c3e\/b0d\/670\/c3eb0d67043391aed585de1eb0aafffc.svg\" alt=\"$\\pi:States\\to Actions$\" data-tex=\"inline\"><\/math>, \u043d\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0430\u0433\u0435\u043d\u0442\u0430 \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438, \u0447\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u0443\u0435\u0442 <b>exploration<\/b>. \u0422.\u0435. \u043c\u044b \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0430\u0433\u0435\u043d\u0442. <\/i><\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c36\/093\/55f\/c3609355f164a03db73ff187d34111ce.svg\" alt=\"$\\tau$\" data-tex=\"inline\"><\/math> \u2014 \u0442\u0440\u0430\u0435\u043a\u0442\u043e\u0440\u0438\u044f, \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u0430\u044f \u0430\u0433\u0435\u043d\u0442\u043e\u043c, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/59a\/eb6\/65a\/59aeb665adb2a4d5f8f354b878c1f4bd.svg\" alt=\"$(s_1, s_2, ..., s_n) $\" data-tex=\"inline\"><\/math>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0430\u0433\u0435\u043d\u0442\u0430 \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c <b>expected return<\/b>:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/544\/0f7\/ee3\/5440f7ee32ee84dcf03887cebc62401c.svg\" alt=\"$J(\\pi)=\\E_{\\tau\\sim\\pi}[R(\\tau)]=\\E_{\\tau\\sim\\pi} \\left[\\sum_{t=0}^n r_t\\right]$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 RL, \u043d\u0430\u0439\u0442\u0438:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/ead\/e8d\/bbd\/eade8dbbd2ebea91cd3d4ee4705da36e.svg\" alt=\"$\\pi^* = arg \\mathop {max} _ \\pi J(\\pi)$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c5e\/d57\/7f6\/c5ed577f6634610da07457db8a7f31fc.svg\" alt=\"$ \\pi^* $\" data-tex=\"inline\"><\/math> \u2014 \u044d\u0442\u043e \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f policy.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043e\u0442 OpenAI: <a href=\"https:\/\/spinningup.openai.com\/en\/latest\/spinningup\/rl_intro.html\" rel=\"nofollow\"> OpenAI Spinning Up<\/a>.<\/p>\n<p>  <a name=\"policy-gradient\"><\/a><\/p>\n<h2>Policy gradient<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 RL \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <b>\u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a<\/b>. \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0431\u044b \u043a\u043b\u0430\u0441\u0441\u043d\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u043e\u0433\u043b\u0438 <b>\u0431\u0440\u0430\u0442\u044c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 expected return \u043f\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u043c\u043e\u0434\u0435\u043b\u0438<\/b>: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/140\/fc5\/34f\/140fc534f78d7ab672e7f28af128d33a.svg\" alt=\"$\\nabla_\\theta J(\\pi_\\theta)$\" data-tex=\"inline\"><\/math>. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0441\u043e\u0432 \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/80b\/1c6\/1c2\/80b1c61c2679da045d117be6a5e33172.svg\" alt=\"$\\theta = \\theta_{old} + \\alpha\\nabla_\\theta J(\\pi_\\theta)$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u044f \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 <b>policy gradient<\/b>. \u0421\u0442\u0440\u043e\u0433\u0438\u0439 \u0432\u044b\u0432\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u0430\u0440\u0434\u043a\u043e\u0440\u043d\u044b\u043c. \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0433\u043e \u0437\u0434\u0435\u0441\u044c, \u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <a href=\"https:\/\/spinningup.openai.com\/en\/latest\/spinningup\/rl_intro3.html\" rel=\"nofollow\"> \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043e\u0442 OpenAI<\/a>. \u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0cb\/465\/b05\/0cb465b05e3683d91fc69d56569fde72.svg\" alt=\"$\\nabla_\\theta J(\\pi_\\theta)=\\E_{\\tau\\sim\\pi_\\theta}\\left[\\sum_{t=0}^T \\nabla_\\theta \\log \\pi_\\theta(a_t|s_t) R(\\tau)\\right]$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c <b>loss<\/b> \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/62f\/e31\/1ba\/62fe311ba7332fbfb6b9c628bc812a4b.svg\" alt=\"$loss = -\\log(\\pi_\\theta(a_t|s_t))R(\\tau)$\" data-tex=\"display\"><\/math><\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d92\/328\/443\/d9232844363fdc5ef95caf0c8f3faf0e.svg\" alt=\"$R(\\tau) = \\sum_{t=0}^T r_t$\" data-tex=\"inline\"><\/math>, \u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/352\/cf2\/6fc\/352cf26fc5970b8a9a884f30e327ae2b.svg\" alt=\"$\\pi_\\theta(a_t|s_t)$\" data-tex=\"inline\"><\/math> \u2014 \u044d\u0442\u043e \u0432\u044b\u0445\u043e\u0434 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0432 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/65b\/2f5\/623\/65b2f5623f5736ddd7e014e4679d4460.svg\" alt=\"$s_t$\" data-tex=\"inline\"><\/math>. \u041c\u0438\u043d\u0443\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0437\u0430 \u0441\u0447\u0451\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/bd0\/d95\/1f3\/bd0d951f37c26136e20b48ee13ee70d2.svg\" alt=\"$J$\" data-tex=\"inline\"><\/math>. \u041f\u0440\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u043d\u0430 \u0431\u0430\u0442\u0447\u0430\u0445 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0441 \u0446\u0435\u043b\u044c\u044e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c <b>variance<\/b>(\u0448\u0443\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0441\u0440\u0435\u0434\u044b).<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f <b>REINFORCE<\/b>. \u0418 \u043e\u043d \u0443\u043c\u0435\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u0440\u0435\u0434. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/gym.openai.com\/envs\/CartPole-v1\/\" rel=\"nofollow\">\u00abCartPole-v1\u00bb<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434 \u0430\u0433\u0435\u043d\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class ActorNetworkDiscrete:     def __init__(self):         self.state_ph = tf.placeholder(tf.float32, shape=[None, observation_space])         l1 = tf.layers.dense(self.state_ph, units=20, activation=tf.nn.relu)         output_linear = tf.layers.dense(l1, units=action_space)          output = tf.nn.softmax(output_linear)         self.action_op = tf.squeeze(tf.multinomial(logits=output_linear,num_samples=1),                                      axis=1)          # Training         output_log = tf.nn.log_softmax(output_linear)          self.weight_ph = tf.placeholder(shape=[None], dtype=tf.float32)         self.action_ph = tf.placeholder(shape=[None], dtype=tf.int32)          action_one_hot = tf.one_hot(self.action_ph, action_space)         responsible_output_log = tf.reduce_sum(output_log * action_one_hot, axis=1)         self.loss = -tf.reduce_mean(responsible_output_log * self.weight_ph)          optimizer = tf.train.AdamOptimizer(learning_rate=actor_learning_rate)         self.update_op = optimizer.minimize(self.loss)  actor = ActorNetworkDiscrete() <\/code><\/pre>\n<p>  <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0435\u0440\u0446\u0435\u043f\u0442\u0440\u043e\u043d \u0442\u0430\u043a\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b: (observation_space, 10, action_space)[\u0434\u043b\u044f CartPole \u044d\u0442\u043e (4, 10, 2)]. <b>tf.multinomial<\/b> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">action = sess.run(actor.action_op,                    feed_dict={actor.state_ph: observation}) <\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u043c \u0435\u0433\u043e \u043e\u0431\u0443\u0447\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">batch_generator = generate_batch(environments,                                  batch_size=batch_size)  for epoch in tqdm_notebook(range(epochs_number)):     batch = next(batch_generator)      # Remainder: batch item consists of [state, action, total reward]     # Train actor     _, actor_loss = sess.run([actor.update_op, actor.loss],                               feed_dict={actor.state_ph: batch[:, 0],                                         actor.action_ph: batch[:, 1],                                         actor.weight_ph: batch[:, 2]}) <\/code><\/pre>\n<p>  <\/p>\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0431\u0430\u0442\u0447\u0435\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0430\u0433\u0435\u043d\u0442\u0430 \u0432 \u0441\u0440\u0435\u0434\u0435 \u0438 \u043a\u043e\u043f\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u042d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0431\u0430\u0442\u0447\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0443\u043f\u043b\u044b \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/490\/b01\/661\/490b0166189da4a3c5c73c79fc81a6b1.svg\" alt=\"$(s_t, a_t, R(\\tau))$\" data-tex=\"inline\"><\/math>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0433\u0434\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u2014 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u0440\u043e\u0433\u043e\u0432\u0438\u0437\u043d\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <b>sess.run()<\/b> \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0434\u043d\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438 (\u0434\u0430\u0436\u0435 MuJoCo). \u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0431\u0430\u0442\u0447\u0430\u0445, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0440\u0435\u0434. <b>\u0414\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0438\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0434\u0430\u0441\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u043e\u0439.<\/b><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c DummyVecEnv \u0438\u0437 OpenAI baselines<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"># Vectorized environments with gym-like interface from baselines.common.vec_env.subproc_vec_env import SubprocVecEnv from baselines.common.vec_env.dummy_vec_env import DummyVecEnv  def make_env(env_id, seed):     def _f():         env = gym.make(env_name)         env.reset()          # Desync environments         for i in range(int(200 * seed \/\/ environments_count)):             env.step(env.action_space.sample())         return env     return _f  envs = [make_env(env_name, seed) for seed in range(environments_count)]  # Can be switched to SubprocVecEnv to parallelize on cores  # (for computationally heavy envs) envs = DummyVecEnv(envs)   # Source:  # https:\/\/github.com\/openai\/spinningup\/blob\/master\/spinup\/algos\/ppo\/core.py def discount_cumsum(x, coef):     \"\"\"     magic from rllab for computing discounted cumulative sums of vectors.     input:          vector x,          [x0,           x1,           x2]     output:         [x0 + discount * x1 + discount^2 * x2,            x1 + discount * x2,          x2]     \"\"\"     return scipy.signal.lfilter([1], [1, float(-coef)], x[::-1], axis=0)[::-1]   def generate_batch(envs, batch_size, replay_buffer_size):     envs_number = envs.num_envs     observations = [[0 for i in range(observation_space)] for i in range(envs_number)]          # [state, action, discounted reward-to-go]     replay_buffer = np.empty((0,3), np.float32)          # [state, action, reward] rollout lists for every environment instance     rollouts = [np.empty((0, 3)) for i in range(envs_number)]      while True:         history = {'reward': [], 'max_action': []}         replay_buffer = replay_buffer[batch_size:]                  # Main sampling cycle         while len(replay_buffer) &lt; replay_buffer_size:             # Here policy acts in environments. Note that it chooses actions for all             # environments in one batch, therefore expensive sess.run is called once.             actions = sess.run(actor.action_op,                                 feed_dict={actor.state_ph: observations})             observations_old = observations             observations, rewards, dones, _ = envs.step(actions)                          history['max_action'].append(np.abs(actions).max())                          time_point = np.array(list(zip(observations_old, actions, rewards)))             for i in range(envs_number):                 # Regular python-like append                 rollouts[i] = np.append(rollouts[i], [time_point[i]], axis=0)                           # Process done==True environments             if dones.all():                 print('WARNING: envs are in sync!! This makes sampling inefficient!')              done_indexes = np.arange(envs_number)[dones]             for i in done_indexes:                 rewards_trajectory = rollouts[i][:, 2].copy()                 history['reward'].append(rewards_trajectory.sum())                  rollouts[i][:, 2] = discount_cumsum(rewards_trajectory,                                                     coef=discount_factor)                 replay_buffer = np.append(replay_buffer, rollouts[i], axis=0)                 rollouts[i] = np.empty((0, 3))                  # Shuffle before yield to become closer to i.i.d.         np.random.shuffle(replay_buffer)                  # Truncate replay_buffer to get the most relevant feedback from environment         replay_buffer = replay_buffer[:replay_buffer_size]         yield replay_buffer[:batch_size], history  # Make a test yield a = generate_batch(envs, 8, 64) # Makes them of equal lenght for i in range(10):     next(a) next(a)[0] <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0430\u0433\u0435\u043d\u0442 \u0443\u043c\u0435\u0435\u0442 \u0438\u0433\u0440\u0430\u0442\u044c \u0432 \u0441\u0440\u0435\u0434\u0430\u0445 \u0441 <b>\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/b>. \u0422\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0410\u0433\u0435\u043d\u0442, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0440\u043e\u0431\u043e\u0442\u043e\u043c, \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440 \u0438\u0437 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b50\/dcc\/35a\/b50dcc35ac6180747faa412600f0754f.svg\" alt=\"$\\R^n$\" data-tex=\"inline\"><\/math>, \u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/08d\/9fa\/efb\/08d9faefbe272bdf8fbb80773542e343.svg\" alt=\"$n$\" data-tex=\"inline\"><\/math> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0435\u043f\u0435\u043d\u0435\u0439 \u0441\u0432\u043e\u0431\u043e\u0434. (<a href=\"https:\/\/arxiv.org\/abs\/1910.07113\" rel=\"nofollow\">\u043b\u0438\u0431\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0430 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0432\u044b\u0445\u043e\u0434\u043e\u043c<\/a>)<\/p>\n<p>  <a name=\"diagonal-gaussian-policies\"><\/a><\/p>\n<h2>Diagonal Gaussian Policies<\/h2>\n<p>  <\/p>\n<p>\u0421\u0443\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0430 <b>Diagonal Gaussian Policies<\/b> \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b n-\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/228\/7f1\/110\/2287f1110a6c8712f48b9c76a5fc4a77.svg\" alt=\"$\\mu_\\theta$\" data-tex=\"inline\"><\/math> \u2014 \u043c\u0430\u0442. \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e34\/b13\/e0e\/e34b13e0ede606045d526556b9453f33.svg\" alt=\"$\\sigma_\\theta$\" data-tex=\"inline\"><\/math> \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435. <b>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0433\u0435\u043d\u0442\u0443 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0431\u0443\u0434\u0435\u043c \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0431\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f.<\/b> \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0430\u0433\u0435\u043d\u0442\u0430\u00a0<math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b50\/dcc\/35a\/b50dcc35ac6180747faa412600f0754f.svg\" alt=\"$\\R^n$\" data-tex=\"inline\"><\/math> \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0435\u0433\u043e \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c. \u0421\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435, \u0447\u0442\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0432 \u043a\u043b\u0430\u0441\u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/215\/302\/99b\/21530299b02fe134ba1a96b070fe9a23.svg\" alt=\"$\\log(\\pi_\\theta(a_t|s_t))$\" data-tex=\"inline\"><\/math> \u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, policy gradient.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e34\/b13\/e0e\/e34b13e0ede606045d526556b9453f33.svg\" alt=\"$\\sigma_\\theta$\" data-tex=\"inline\"><\/math> \u043a\u0430\u043a \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0445\u043e\u0434\u0430. \u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u043d\u043e\u0441\u0438\u0442 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0432\u0440\u0435\u0434\u0430, \u0430, \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/spinningup.openai.com\/en\/latest\/spinningup\/rl_intro.html#stochastic-policies\" rel=\"nofollow\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 policy<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u0430\u0433\u0435\u043d\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">epsilon = 1e-8  def gaussian_loglikelihood(x, mu, log_std):     pre_sum = -0.5 * (((x - mu) \/ (tf.exp(log_std) + epsilon))**2 + 2 * log_std + np.log(2 * np.pi))     return tf.reduce_sum(pre_sum, axis=1)  class ActorNetworkContinuous:     def __init__(self):         self.state_ph = tf.placeholder(tf.float32, shape=[None, observation_space])          l1 = tf.layers.dense(self.state_ph, units=100, activation=tf.nn.tanh)         l2 = tf.layers.dense(l1, units=50, activation=tf.nn.tanh)         l3 = tf.layers.dense(l2, units=25, activation=tf.nn.tanh)         mu = tf.layers.dense(l3, units=action_space)          log_std = tf.get_variable(name='log_std',                                    initializer=-0.5 * np.ones(action_space,          std = tf.exp(log_std)          self.action_op = mu + tf.random.normal(shape=tf.shape(mu)) * std          # Training         self.weight_ph = tf.placeholder(shape=[None], dtype=tf.float32)         self.action_ph = tf.placeholder(shape=[None, action_space], dtype=tf.float32)          action_logprob = gaussian_loglikelihood(self.action_ph, mu, log_std)         self.loss = -tf.reduce_mean(action_logprob * self.weight_ph)                  optimizer = tf.train.AdamOptimizer(learning_rate=actor_learning_rate)         self.update_op = optimizer.minimize(self.loss) <\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0430\u0441\u0442\u044c \u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a REINFORCE \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0441 \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u0417\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u0435\u0435 \u0446\u0435\u043b\u044c \u0430\u0433\u0435\u043d\u0442\u0430 \u2014 \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432\u043f\u0440\u0430\u0432\u043e.<\/p>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/eH8cFxYHhQg?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u043d\u043e \u0432\u0435\u0440\u043d\u043e \u043f\u043e\u043b\u0437\u0451\u0442 \u043a \u0441\u0432\u043e\u0435\u0439 \u0446\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<h3>Reward-to-go<\/h3>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0435 \u0435\u0441\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u0447\u043b\u0435\u043d\u044b. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0448\u0430\u0433\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9b0\/012\/4e4\/9b00124e411362185d05b841bc32695f.svg\" alt=\"$t$\" data-tex=\"inline\"><\/math> \u043f\u0440\u0438 \u0432\u0437\u0432\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0438 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443 <b>\u0437\u0430 \u0432\u0441\u044e \u0442\u0440\u0430\u0435\u043a\u0442\u043e\u0440\u0438\u044e<\/b>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0430\u0433\u0435\u043d\u0442\u0430 \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e. \u0417\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0442 \u044d\u0442\u043e<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a9b\/9b1\/d5f\/a9b9b1d5f7b90267b7387b5efc759a61.svg\" alt=\"$\\nabla_\\theta J(\\pi_\\theta)=\\E_{\\tau\\sim\\pi_\\theta}\\left[\\sum_{t=0}^T \\nabla_\\theta \\log \\pi_\\theta(a_t|s_t) \\sum_{t'=0}^T r_{t'}\\right]$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u043e\u0442 \u044d\u0442\u0438\u043c<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/654\/fb5\/cfb\/654fb5cfb6f3e64a6e1ba4235f4b1d5e.svg\" alt=\"$\\nabla_\\theta J(\\pi_\\theta)=\\E_{\\tau\\sim\\pi_\\theta}\\left[\\sum_{t=0}^T \\nabla_\\theta \\log \\pi_\\theta(a_t|s_t) \\sum_{t'=t}^T r_{t'}\\right]$\" data-tex=\"display\"><\/math><\/p>\n<p>\u041d\u0430\u0439\u0434\u0438\u0442\u0435 10 \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \ud83d\ude42<\/p>\n<p>  <\/p>\n<p>\u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u044d\u0442\u0438\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0440\u0442\u0438\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u044d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0448\u0443\u043c\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u0430\u0433\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0442\u0435 \u043d\u0430\u0433\u0440\u0430\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b <b>\u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/b>.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0439 reward \u0432\u044b\u0440\u043e\u0441. \u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u043d\u0430\u0443\u0447\u0438\u043b\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0439 \u0446\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/8sN-VaQsnVU?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <a name=\"add-critic\"><\/a><\/p>\n<h2>\u0423\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c variance \u043f\u0443\u0442\u0451\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430<\/h2>\n<p>  <\/p>\n<p>\u0421\u0443\u0442\u044c\u044e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0448\u0443\u043c\u0430 (variance), \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0438\u0437-\u0437\u0430 \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 \u0441\u0440\u0435\u0434\u044b.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <b>\u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0441\u0443\u043c\u043c\u0443 \u043d\u0430\u0433\u0440\u0430\u0434<\/b>, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u043c, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f9d\/da2\/695\/f9dda26950cb67bd3ecef956c5341c14.svg\" alt=\"$s$\" data-tex=\"inline\"><\/math> \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0442\u0440\u0430\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0442.\u0435. Value-\u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d0a\/098\/ecf\/d0a098ecf6023f8b38130278711fd86f.svg\" alt=\"$V^\\pi(s)=\\E_{\\tau\\sim\\pi}\\left[R(\\tau)|s_0=s\\right]\\text{ - Value function}$\" data-tex=\"display\"><\/math><\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/671\/6f0\/d8b\/6716f0d8b503d3ee5c194737b0f3543a.svg\" alt=\"$Q^\\pi(s, a)=\\E_{\\tau\\sim\\pi}\\left[R(\\tau)|s_0=s, a_0=a\\right]\\text{ - Action-Value function}$\" data-tex=\"display\"><\/math><\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/262\/e1a\/de2\/262e1ade24d353a464224b0a20247db8.svg\" alt=\"$A^\\pi(s, a)=Q^\\pi(s, a)-V^\\pi(s)\\text{ - Advantage function}$\" data-tex=\"display\"><\/math><\/p>\n<p>Value-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 expected return, \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u0430 policy \u043d\u0430\u0447\u043d\u0451\u0442 \u0438\u0433\u0440\u0443 \u0438\u0437 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 Q-\u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0449\u0451 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0441\u0430\u043c\u043e\u0435 \u043f\u0435\u0440\u0432\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<\/p>\n<p>  <\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u0440\u0438\u0442\u0438\u043a\u0430<\/h3>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 reward-to-go:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c42\/195\/d5d\/c42195d5d8b5b68e31b925e5a24cc255.svg\" alt=\"$\\nabla_\\theta \\log \\pi_\\theta(a_t|s_t) \\sum_{t'=t}^T r_{t'}$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u043c \u043f\u0440\u0438 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0435 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0438 \u0447\u0442\u043e \u0438\u043d\u043e\u0435, \u043a\u0430\u043a \u0441\u044d\u043c\u043f\u043b Value-\u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b27\/c7a\/1a4\/b27c7a1a4a4d3e8643f1018db155ad16.svg\" alt=\"$\\sum_{t'=t}^T r_{t'} \\sim V^\\pi(s_t)$\" data-tex=\"display\"><\/math><\/p>\n<p>\u041c\u044b \u0432\u0437\u0432\u0435\u0448\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430 \u043e\u0434\u043d\u0438\u043c \u0441\u044d\u043c\u043f\u043b\u043e\u043c \u0438\u0437 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0442\u0440\u0430\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0447\u0442\u043e \u043d\u0435 \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e. <b>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c Value-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u044c\u044e, \u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443 \u043d\u0435\u0451, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0435\u0449\u0451 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0432 variance.<\/b> \u041d\u0430\u0437\u043e\u0432\u0451\u043c \u044d\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u044c <b>\u043a\u0440\u0438\u0442\u0438\u043a\u043e\u043c (Critic)<\/b> \u0438 \u0431\u0443\u0434\u0435\u043c \u0443\u0447\u0438\u0442\u044c \u0435\u0451 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441 policy. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9af\/e55\/840\/9afe5584019013b7295de937c4f6b012.svg\" alt=\"$\\nabla_\\theta \\log \\pi_\\theta(a_t|s_t) \\sum_{t'=t}^T r_{t'} \\approx \\nabla_\\theta \\log \\pi_\\theta(a_t|s_t) V^\\pi(\\tau)$\" data-tex=\"display\"><\/math><\/p>\n<p>\u041c\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0438 variance, \u043d\u043e \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u044b \u0432\u043d\u0435\u0441\u043b\u0438 <b>bias<\/b> \u0432 \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438. \u041d\u043e \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c. \u0422\u0430\u043a\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <b><a href=\"https:\/\/towardsdatascience.com\/understanding-the-bias-variance-tradeoff-165e6942b229\" rel=\"nofollow\">bias-variance tradeoff<\/a><\/b>.<\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u0438\u0442\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0443\u0447\u0438\u0442\u044c Value-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0435\u0439 \u043f\u043e \u0441\u044d\u043c\u043f\u043b\u0430\u043c reward-to-go, \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u043c \u0432 \u0441\u0440\u0435\u0434\u0435. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u043e\u0437\u044c\u043c\u0451\u043c MSE. \u0422.\u0435. loss \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5d0\/d06\/8ee\/5d0d068eeb5a9992f4180373bf00252b.svg\" alt=\"$loss = ({V}^\\pi_\\psi(s_t)-\\sum_{t'=t}^T r_{t'})^2$\" data-tex=\"display\"><\/math><\/p>\n<p>\u041a\u043e\u0434 \u043a\u0440\u0438\u0442\u0438\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class CriticNetwork:     def __init__(self):         self.state_ph = tf.placeholder(tf.float32, shape=[None, observation_space])          l1 = tf.layers.dense(self.state_ph, units=100, activation=tf.nn.tanh)                 l2 = tf.layers.dense(l1, units=50, activation=tf.nn.tanh)         l3 = tf.layers.dense(l2, units=25, activation=tf.nn.tanh)         output = tf.layers.dense(l3, units=1)                  self.value_op = tf.squeeze(output, axis=-1)          # Training         self.value_ph = tf.placeholder(shape=[None], dtype=tf.float32)                  self.loss = tf.losses.mean_squared_error(self.value_ph, self.value_op)                  optimizer = tf.train.AdamOptimizer(learning_rate=critic_learning_rate)         self.update_op = optimizer.minimize(self.loss) <\/code><\/pre>\n<p>  <\/p>\n<p>\u0426\u0438\u043a\u043b \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">batch_generator = generate_batch(envs,                                  batch_size=batch_size)  for epoch in tqdm_notebook(range(epochs_number)):     batch = next(batch_generator)      # Remainder: batch item consists of [state, action, value, reward-to-go]     # Train actor     _, actor_loss = sess.run([actor.update_op, actor.loss],                               feed_dict={actor.state_ph: batch[:, 0],                                         actor.action_ph: batch[:, 1],                                         actor.weight_ph: batch[:, 2]})          # Train critic     for j in range(10):         _, critic_loss = sess.run([critic.update_op, critic.loss],                                    feed_dict={critic.state_ph: batch[:, 0],                                              critic.value_ph: batch[:, 3]}) <\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0431\u0430\u0442\u0447\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, value, \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0435 \u043a\u0440\u0438\u0442\u0438\u043a\u043e\u043c \u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0435.<br \/>  \u0422.\u0435. \u0432\u0438\u0434 \u0431\u0430\u0442\u0447\u0430 \u0442\u0430\u043a\u043e\u0439: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/912\/a06\/8f4\/912a068f4e0be232003b407a30c6dc69.svg\" alt=\"$ (s_t, a_t, V^\\pi_\\psi(s_t), \\sum_{t'=t}^T r_{t'}) $\" data-tex=\"inline\"><\/math>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0446\u0438\u043a\u043b\u0435 \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0441 \u043e\u0442 <b>\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430 \u0434\u043e \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438<\/b>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u0443\u0441\u043a\u0430, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u043b\u0443\u0447\u0448\u0430\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044e Value-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f bias. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0430\u0442\u0447\u0430, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. <b>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 policy \u043d\u0435 \u0432\u0435\u0440\u043d\u043e.<\/b> \u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043c\u0435\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u043e\u0442 \u0441\u0440\u0435\u0434\u044b \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0448\u0442\u0440\u0430\u0444\u0443\u0435\u043c policy \u0437\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0430 \u0431\u044b \u0443\u0436\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043b\u0430. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <b>on-policy<\/b>.<\/p>\n<p>  <\/p>\n<h3>Baselines in Policy Gradients<\/h3>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0435 \u043d\u0430 \u043c\u0435\u0441\u0442\u043e Value-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0442 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9b0\/012\/4e4\/9b00124e411362185d05b841bc32695f.svg\" alt=\"$t$\" data-tex=\"inline\"><\/math>. \u0422\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <b>baselines<\/b>. (<a href=\"https:\/\/spinningup.openai.com\/en\/latest\/spinningup\/rl_intro3.html#baselines-in-policy-gradients\" rel=\"nofollow\">\u0412\u044b\u0432\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u0430<\/a>) \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0435\u0439\u0437\u043b\u0430\u0439\u043d\u043e\u0432 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u0435\u0431\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/c8\/ah\/l7\/c8ahl70po6_pgcud0jxdfbmubi8.png\">  <\/p>\n<p><i>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a href=\"https:\/\/arxiv.org\/pdf\/1506.02438.pdf\" rel=\"nofollow\">GAE paper<\/a>.<\/i><\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u043d\u044b\u0435 \u0431\u0435\u0439\u0437\u043b\u0430\u0439\u043d\u044b \u0434\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043f\u0440\u043e\u0444\u0438\u0442 \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u0430\u0451\u0442 <b>Advantage-\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/b> \u0438 \u0435\u0451 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430 \u044d\u0442\u0438\u043c \u0434\u0430\u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438\u043d\u0442\u0443\u0438\u0446\u0438\u044f. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Advantage, \u043c\u044b \u0448\u0442\u0440\u0430\u0444\u0443\u0435\u043c \u0430\u0433\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0442\u043e\u043c\u0443, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0443\u0447\u0448\u0435 \u0438\u043b\u0438 \u0445\u0443\u0436\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0441\u0430\u043c \u0430\u0433\u0435\u043d\u0442 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0451\u043d\u043d\u043e\u0435 \u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0418 \u0447\u0435\u043c \u043b\u0443\u0447\u0448\u0435 \u0430\u0433\u0435\u043d\u0442 \u0438\u0433\u0440\u0430\u0435\u0442 \u0432 \u0441\u0440\u0435\u0434\u0435, \u0442\u0435\u043c <b>\u0432\u044b\u0448\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0435\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b<\/b>. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0433\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0433\u0440\u0430\u0442\u044c \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0430\u043a \u0438\u043c\u0435\u044e\u0449\u0438\u0435 Advantage \u0440\u0430\u0432\u043d\u044b\u0439 0 \u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u043c\u0435\u0442\u044c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0440\u0430\u0432\u043d\u044b\u0439 0.<\/p>\n<p>  <\/p>\n<h3>\u041e\u0446\u0435\u043d\u043a\u0430 Advantage \u0447\u0435\u0440\u0435\u0437 Value-\u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 Advantage:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/262\/e1a\/de2\/262e1ade24d353a464224b0a20247db8.svg\" alt=\"$A^\\pi(s, a)=Q^\\pi(s, a)-V^\\pi(s)\\text{ - Advantage function}$\" data-tex=\"display\"><\/math><\/p>\n<p>\u041d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044f\u0432\u043d\u043e. \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0434\u0451\u0442 \u0442\u0440\u044e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0432\u0435\u0434\u0451\u0442 \u043f\u043e\u0434\u0441\u0447\u0451\u0442 Advantage-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a \u043f\u043e\u0434\u0441\u0447\u0451\u0442\u0443 Value-\u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/703\/f3e\/ebf\/703f3eebfa3b59e8b4fd6fabbd10216d.svg\" alt=\"$\\delta_t^V = r_t+V(s_{t+1})-V(s_t)$\" data-tex=\"inline\"><\/math> \u2014 Temporal Difference residual (<b>TD-residual<\/b>). \u041d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438, \u0447\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u0443\u0435\u0442 Advantage:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/933\/9e3\/531\/9339e3531056f2c82a597484d424970b.svg\" alt=\"$\\E\\left[\\delta^V_t\\right] = \\E\\left[r_t+V(s_{t+1})-V(s_t)\\right] = \\E\\left[Q(s_t, a_t)-V(s_t)\\right]=A(s_t, a_t)$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0422\u0430\u043a\u043e\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u0443\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u0434\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0446\u0435\u043d\u043a\u0438 Value-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0440\u0438\u0442\u0438\u043a\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 policy \u043e\u0446\u0435\u043d\u043a\u0443 Advantage.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <b>Advantage Actor-Critic<\/b>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def estimate_advantage(states, rewards):     values = sess.run(critic.value_op, feed_dict={critic.state_ph: states})     deltas = rewards - values     deltas = deltas + np.append(values[1:], np.array([0]))          return deltas, values <\/code><\/pre>\n<p>  <\/p>\n<p>\u0423 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0445\u043e\u0434\u043a\u0443 \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/GCbPl3dOLmQ?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3>Generalized Advantage Estimation<\/h3>\n<p>  <\/p>\n<p>\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0432\u044b\u0448\u0435\u0434\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f (2018) &#171;<a href=\"https:\/\/arxiv.org\/pdf\/1506.02438.pdf\" rel=\"nofollow\">High-dimensional continuous control using generalized advantage estamation<\/a>&#187; \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 Advantage \u0447\u0435\u0440\u0435\u0437 Value-\u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041e\u043d\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 variance \u0435\u0449\u0451 \u0441\u0438\u043b\u044c\u043d\u0435\u0435:<\/p>\n<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d52\/f42\/4d1\/d52f424d1a04f552c0a1ce2597ab044e.svg\" alt=\"$A_t^{GAE(\\gamma,\\lambda)} = \\sum_{l=0}^\\infty (\\gamma\\lambda)^l\\delta^V_{t+l}$\" data-tex=\"display\"><\/math><\/p>\n<p>\u0433\u0434\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/703\/f3e\/ebf\/703f3eebfa3b59e8b4fd6fabbd10216d.svg\" alt=\"$\\delta_t^V = r_t+V(s_{t+1})-V(s_t)$\" data-tex=\"inline\"><\/math> \u2014 TD-residual,<\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/fbc\/f2a\/da4\/fbcf2ada4d2c9c0d4c2e64f59ffe82c0.svg\" alt=\"$\\gamma$\" data-tex=\"inline\"><\/math> \u2014 discount-\u0444\u0430\u043a\u0442\u043e\u0440 (\u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440),<\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b1b\/c57\/ea8\/b1bc57ea859ea7d6505ec3a3ae9be2f6.svg\" alt=\"$\\lambda$\" data-tex=\"inline\"><\/math> \u2014 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0430\u043c\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def discount_cumsum(x, coef):     # Source:      # https:\/\/github.com\/openai\/spinningup\/blob\/master\/spinup\/algos\/ppo\/core.py     \"\"\"     magic from rllab for computing discounted cumulative sums of vectors.     input:          vector x,          [x0,           x1,           x2]     output:         [x0 + discount * x1 + discount^2 * x2,            x1 + discount * x2,          x2]     \"\"\"     return scipy.signal.lfilter([1], [1, float(-coef)], x[::-1], axis=0)[::-1]   def estimate_advantage(states, rewards):     values = sess.run(critic.value_op, feed_dict={critic.state_ph: states})     deltas = rewards - values     deltas = deltas + discount_factor * np.append(values[1:], np.array([0]))          advantage = discount_cumsum(deltas, coef=lambda_factor * discount_factor)     return advantage, values <\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0430\u0442\u0447\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u043f\u0442\u0438\u043c\u0443\u043c\u0430\u043c. \u0417\u0434\u0435\u0441\u044c \u0430\u0433\u0435\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0434\u043d\u0443 \u043b\u0430\u043f\u0443 \u043a\u0430\u043a \u0442\u0440\u043e\u0441\u0442\u044c, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/3f4rRbqnuxg?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u0430\u0433\u0435\u043d\u0442 \u043d\u0435 \u043f\u0440\u0438\u0448\u0451\u043b \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u044b\u0436\u043a\u043e\u0432, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a \u043e\u043d \u0432\u0435\u0434\u0451\u0442 \u0441\u0435\u0431\u044f, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u043d\u0451\u0442\u0441\u044f \u2014 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0431\u0435\u0433:<\/p>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/O5aJoj16ZDM?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041b\u0443\u0447\u0448\u0438\u0439 \u0430\u0433\u0435\u043d\u0442, \u043e\u043d \u0436\u0435 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438. \u041f\u0435\u0440\u0435\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u043c\u0438 \u043f\u0440\u044b\u0436\u043a\u0430\u043c\u0438, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0442 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438. \u0420\u0430\u0437\u0432\u0438\u0442\u043e\u0435 \u0443\u043c\u0435\u043d\u0438\u0435 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0433\u0435\u043d\u0442\u0443 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u0430 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/xT9KKnpxxo8?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <a name=\"pitfalls\"><\/a><\/p>\n<h2>\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/h2>\n<p>  <\/p>\n<p>\u041c\u0430\u0448\u0438\u043d\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0430\u0432\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043e\u0448\u0438\u0431\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c, \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u041d\u043e RL \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0430 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rq\/w0\/fl\/rqw0flwtyhb3getoyjwyraaf7na.png\">  <\/p>\n<p><a href=\"http:\/\/ai.stanford.edu\/~zayd\/why-is-machine-learning-hard.html\" rel=\"nofollow\"><i>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/i><\/a><\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d \u043a \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c. \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 learning rate \u0441 3e-4 \u043d\u0430 1e-4. \u0418 \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u0440\u0430\u0434\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u2014 \u0441 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0434\u043e \u043b\u0443\u0447\u0448\u0435\u0433\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u0432\u0438\u0434\u0435\u043e.<\/li>\n<li>\u0420\u0430\u0437\u043c\u0435\u0440 \u0431\u0430\u0442\u0447\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u0445 DL. \u0415\u0441\u043b\u0438 \u0432 image classification \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0430\u0442\u0447\u0430 32-256 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043e\u0442 \u0435\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f, \u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043b\u0443\u0447\u0448\u0435 \u0432\u0437\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u044b\u0441\u044f\u0447, \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 3000. \u0418 \u0441\u043d\u043e\u0432\u0430 \u043e\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/li>\n<li>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0438\u043d\u043e\u0433\u0434\u0430 \u0441 random seed \u043d\u0435 \u0432\u0435\u0437\u0451\u0442.<\/li>\n<li>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0432 \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0438 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043b\u0443\u0447\u0448\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0443\u0447\u0430\u043b\u0441\u044f 8 \u0447\u0430\u0441\u043e\u0432, 3 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0445\u0443\u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0431\u0435\u0439\u0437\u043b\u0430\u0439\u043d\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043b\u0443\u0447\u0448\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441 \u043c\u0430\u043b\u043e\u0433\u043e \u0432\u0440\u043e\u0434\u0435 \u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u0445 \u0441\u0440\u0435\u0434 \u0438\u0437 gym.<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ol\/ml\/yx\/olmlyxvpvt8lroty8kllva2igz4.png\"><\/li>\n<li>\u0425\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u043a \u043f\u043e\u0438\u0441\u043a\u0443 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043f\u043e \u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435. (\u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0430\u0442\u044c\u0441\u044f)<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u044e\u0430\u043d\u0441\u043e\u0432 \u0432 Deep RL \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438: <a href=\"https:\/\/www.alexirpan.com\/2018\/02\/14\/rl-hard.html\" rel=\"nofollow\">Deep Reinforcement Learning Doesn&#8217;t Work Yet<\/a>.<\/p>\n<p>  <a name=\"conclusion\"><\/a><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u0430\u0439\u0434\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/58b\/1fa\/2db\/58b1fa2db2666c108358f79dd43a632b.svg\" alt=\"$\\pi:\\R^{800}\\to\\R^{18}$\" data-tex=\"inline\"><\/math>, \u043f\u0440\u043e\u0432\u043e\u0440\u043d\u043e \u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0431\u043b\u0438\u0437\u043a\u0438\u0445 \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u0432 A2C, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 PPO \u0438 TRPO. \u041e\u043d\u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 <b>sample efficiency<\/b>, \u0442.\u0435. \u0432\u0440\u0435\u043c\u044f \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0438 \u0443\u043c\u0435\u044e\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u0418\u043c\u0435\u043d\u043d\u043e PPO + Automatic Domain Randomization \u043d\u0435\u0434\u0430\u0432\u043d\u043e <a href=\"https:\/\/openai.com\/blog\/solving-rubiks-cube\/\" rel=\"nofollow\">\u0441\u043e\u0431\u0440\u0430\u043b \u041a\u0443\u0431\u0438\u043a \u0420\u0443\u0431\u0438\u043a\u0430 \u043d\u0430 \u0440\u043e\u0431\u043e\u0442\u0435<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u0434 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438: <a href=\"https:\/\/github.com\/LeonidMurashov\/advantage-actor-critic-gae\" rel=\"nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u0438 \u0432\u044b \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u0443\u0436\u0435 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0443\u043c\u0435\u0435\u0442 Deep Reinforcement Learning.<\/p>\n<p>  <\/p>\n<p><b>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/b><\/p>\n<p>  <\/p>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/spinningup.openai.com\/en\/latest\/index.html\" rel=\"nofollow\">Welcome to Spinning Up in Deep RL!<\/a><\/li>\n<li><a href=\"http:\/\/rail.eecs.berkeley.edu\/deeprlcourse-fa17\/index.html\" rel=\"nofollow\">CS 294: Deep Reinforcement Learning, Fall 2017<\/a><\/li>\n<li><a href=\"https:\/\/arxiv.org\/pdf\/1506.02438.pdf\" rel=\"nofollow\">High-dimensional continuous control using generalized advantage estamation<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/openai\/baselines\/\" rel=\"nofollow\">OpenAI Baselines: high-quality implementations of reinforcement learning algorithms<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p><i>\u0421\u043f\u0430\u0441\u0438\u0431\u043e <a href=\"https:\/\/habr.com\/ru\/users\/pinkotter\/\" class=\"user_link\">pinkotter<\/a> \u0437\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c.<\/i><\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/483078\/\"> https:\/\/habr.com\/ru\/post\/483078\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483078\/\">\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/rxWmEnWR3jw?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0433\u043b\u0443\u0431\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u0434\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c. \u0412\u043a\u0440\u0430\u0442\u0446\u0435, \u043f\u043e\u0432\u0435\u0434\u0430\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u00ab\u0447\u0451\u0440\u043d\u044b\u0439 \u044f\u0449\u0438\u043a \u0441 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044f\u043c\u0438\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0440\u043e\u0431\u043e\u0442\u0430, \u0430 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0432\u044b\u0434\u0430\u0451\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c <b>Advantage Actor Critic<\/b> (A2C) \u0441 \u043e\u0446\u0435\u043d\u043a\u043e\u0439 Advantage \u0447\u0435\u0440\u0435\u0437 <b>Generalized Advantage Estimation<\/b> (GAE).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 TensorFlow \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0435\u043c\u043e\u043a \u0442\u043e\u0433\u043e, \u043a \u043a\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c \u0445\u043e\u0434\u044c\u0431\u044b \u0441\u043e\u0448\u043b\u0438\u0441\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b.<\/p>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-296837","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296837"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296837\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}