spinup/algos/pytorch/ppo_lstm/core_lstm.py
def calc_discounted_return(rewards, discount, final_value):
    """
    Calculate discounted returns based on rewards and discount factor.
    """
    seq_len = len(rewards)
    discounted_returns = torch.zeros(seq_len)
    discounted_returns[-1] = rewards[-1] + discount * final_value
    for i in range(seq_len - 2, -1 , -1):
        discounted_returns[i] = rewards[i] + discount * discounted_returns[i + 1]
    return discounted_returns

    Calculate discounted returns based on rewards and discount factor.
    
Calculate discounted returns based on rewards and discount factor.
Calculate discounted returns based on rewards and discount factor .
def calc_discounted_return(rewards, discount, final_value):
    seq_len = len(rewards)
    discounted_returns = torch.zeros(seq_len)
    discounted_returns[-1] = rewards[-1] + discount * final_value
    for i in range(seq_len - 2, -1 , -1):
        discounted_returns[i] = rewards[i] + discount * discounted_returns[i + 1]
    return discounted_returns
def calc_discounted_return ( rewards , discount , final_value ) : seq_len = len ( rewards ) discounted_returns = torch . zeros ( seq_len ) discounted_returns [ - 1 ] = rewards [ - 1 ] + discount * final_value for i in range ( seq_len - 2 , - 1 , - 1 ) : discounted_returns [ i ] = rewards [ i ] + discount * discounted_returns [ i + 1 ] return discounted_returns
Calculate discounted returns based on rewards and discount factor.
Calculate discounted returns based on rewards and discount factor .
"""
    Calculate discounted returns based on rewards and discount factor.
    """
rewards
discount
final_value