การคำนวณ Discounted Return สำหรับกลยุทธ์ของ Agent
Discounted return ช่วยในการประเมินรางวัลรวมที่ agent คาดว่าจะได้รับตลอดช่วงเวลา โดยคำนึงว่ารางวัลในอนาคตมีมูลค่าน้อยกว่ารางวัลที่ได้รับในทันที คุณได้รับรางวัลที่คาดหวังสำหรับสองกลยุทธ์ที่แตกต่างกัน (exp_rewards_strategy_1 และ exp_rewards_strategy_2) ของ RL agent โดยมีโจทย์คือการคำนวณ discounted return ของแต่ละกลยุทธ์ และระบุว่ากลยุทธ์ใดให้ผลตอบแทนสูงกว่า
ไลบรารี numpy ถูก import ให้แล้วในชื่อ np
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Reinforcement Learning with Gymnasium ใน Python
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
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}")