始める無料で始める

エージェントの戦略に対する割引リターンを計算する

割引リターンは、将来の報酬は即時の報酬より価値が低いことを考慮しつつ、エージェントが時間とともに得られる総報酬の見込みを評価するために使います。ここでは、あるRLエージェントの2つの異なる戦略(exp_rewards_strategy_1exp_rewards_strategy_2)に対する期待報酬が与えられています。各戦略の割引リターンを計算し、どちらの戦略がより高いリターンをもたらすかを判断してください。

numpy ライブラリは np としてインポート済みです。

この演習はコースの一部です

Pythonで学ぶGymnasiumによるReinforcement Learning

コースを見る

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

exp_rewards_strategy_1 = np.array([3, 2, -1, 5])

discount_factor = 0.9

# Compute discounts
discounts_strategy_1 = np.array([____ for i in range(len(exp_rewards_strategy_1))])

# Compute the discounted return
discounted_return_strategy_1 = np.sum(____)

print(f"The discounted return of the first strategy is {discounted_return_strategy_1}")
コードを編集して実行