- PyTorch 1.x Reinforcement Learning Cookbook
- Yuxi (Hayden) Liu
- 238字
- 2021-06-24 12:34:43
How it works...
The policy gradient algorithm trains an agent by taking small steps and updating the weight based on the rewards associated with those steps at the end of an episode. The technique of having the agent run through an entire episode and then updating the policy based on the rewards obtained is called Monte Carlo policy gradient.
The action is selected based on the probability distribution computed based on the current state and the model’s weight. For example, if the probabilities for the left and right actions are [0.6, 0.4], this means the left action is selected 60% of the time; it doesn't mean the left action is chosen, as in the random search and hill-climbing algorithms.
We know that the reward is 1 for each step before an episode terminates. Hence, the future reward we use to calculate the policy gradient at each step is the number of steps remaining. After each episode, we feed the gradient history multiplied by the future rewards to update the weight using the stochastic gradient ascent method. In this way, the longer an episode is, the bigger the update of the weight. This will eventually increase the chance of getting a larger total reward.
As we mentioned at the start of this section, the policy gradient algorithm might be overkill for a simple environment such as CartPole, but it should get us ready for more complicated problems.
- 腦動(dòng)力:PHP函數(shù)速查效率手冊(cè)
- 工業(yè)機(jī)器人工程應(yīng)用虛擬仿真教程:MotoSim EG-VRC
- 自主研拋機(jī)器人技術(shù)
- RPA(機(jī)器人流程自動(dòng)化)快速入門(mén):基于Blue Prism
- 基于32位ColdFire構(gòu)建嵌入式系統(tǒng)
- 完全掌握AutoCAD 2008中文版:機(jī)械篇
- 工業(yè)控制系統(tǒng)測(cè)試與評(píng)價(jià)技術(shù)
- 網(wǎng)絡(luò)管理工具實(shí)用詳解
- Extending Ansible
- 工業(yè)機(jī)器人實(shí)操進(jìn)階手冊(cè)
- 人工智能:智能人機(jī)交互
- WPF專業(yè)編程指南
- ASP.NET學(xué)習(xí)手冊(cè)
- fastText Quick Start Guide
- Hands-On Artificial Intelligence for Beginners