시작하기무료로 시작하기

에이전트 전략의 할인된 반환 계산하기

할인된 반환(discounted return)은 시간이 지남에 따라 에이전트가 기대할 수 있는 보상의 총합을 평가할 때 사용하며, 미래 보상은 즉시 보상보다 가치가 낮다는 점을 반영합니다. RL 에이전트의 두 가지 서로 다른 전략(exp_rewards_strategy_1, exp_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}")
코드 편집 및 실행