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

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.

主站蜘蛛池模板: 泸定县| 娱乐| 上蔡县| 洛浦县| 盐源县| 伊川县| 伽师县| 石楼县| 南丰县| 安康市| 静海县| 宝山区| 阿克苏市| 修文县| 麻江县| 文山县| 崇文区| 滦南县| 普宁市| 江津市| 皋兰县| 吴堡县| 岗巴县| 天津市| 万州区| 阿鲁科尔沁旗| 濮阳市| 成武县| 柳江县| 康平县| 个旧市| 金乡县| 商水县| 玉环县| 江都市| 临漳县| 永定县| 林芝县| 阿拉善左旗| 民和| 商城县|