官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 临高县| 宝山区| 石阡县| 扎囊县| 河源市| 嘉兴市| 灵石县| 武乡县| 孟连| 县级市| 万年县| 清流县| 山丹县| 霍林郭勒市| 河津市| 龙口市| 东海县| 虞城县| 和硕县| 沾化县| 牟定县| 泸溪县| 长白| 松阳县| 高密市| 仁寿县| 施甸县| 香港 | 新丰县| 西和县| 浦东新区| 孟州市| 阜城县| 肃宁县| 台中市| 永年县| 通渭县| 怀集县| 义马市| 湖口县| 大安市|