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

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.

主站蜘蛛池模板: 苍梧县| 祁东县| 中牟县| 奉化市| 大足县| 安塞县| 甘泉县| 南岸区| 田阳县| 六枝特区| 宜川县| 梁平县| 黎川县| 青冈县| 交口县| 乌海市| 天柱县| 鹤壁市| 镇赉县| 体育| 合水县| 平武县| 枣强县| 永泰县| 蒙自县| 诸暨市| 南涧| 鹤壁市| 苍山县| 博乐市| 微博| 宁波市| 四川省| 米易县| 噶尔县| 五常市| 鄂托克旗| 广昌县| 赤峰市| 宁晋县| 泰兴市|