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

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.

主站蜘蛛池模板: 陈巴尔虎旗| 红桥区| 甘洛县| 炉霍县| 杭锦旗| 五指山市| 隆安县| 延安市| 太仆寺旗| 萝北县| 南阳市| 桐梓县| 田阳县| 南岸区| 兴仁县| 古蔺县| 新竹市| 曲沃县| 澎湖县| 航空| 宁陕县| 宜君县| 象州县| 中山市| 凤冈县| 赣榆县| 卓尼县| 安阳县| 龙海市| 乌拉特中旗| 芦山县| 新密市| 南靖县| 江口县| 锡林郭勒盟| 乐业县| 商南县| 北票市| 邵东县| 收藏| 绥滨县|