(self, gamma)
Calculate discounted returns.
Calculate discounted returns.
Calculate discounted returns .
def calculate_returns(self, gamma):
    """Calculate discounted returns."""
    rewards = np.array([ts.reward for ts in self._timesteps])
    discount_mask = np.array([
        ts.env_info.discount_mask for ts in self._timesteps
    ])
    gammas = advantages.mask_discount(gamma, discount_mask)
    returns = advantages.discounted_returns(rewards, gammas)
    for (i, return_) in enumerate(returns):
      self._timesteps[i] = self._timesteps[i]._replace(return_=return_)
def calculate_returns ( self , gamma ) : rewards = np . array ( [ ts . reward for ts in self . _timesteps ] ) discount_mask = np . array ( [ ts . env_info . discount_mask for ts in self . _timesteps ] ) gammas = advantages . mask_discount ( gamma , discount_mask ) returns = advantages . discounted_returns ( rewards , gammas ) for ( i , return_ ) in enumerate ( returns ) : self . _timesteps [ i ] = self . _timesteps [ i ] . _replace ( return_ = return_ )