Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tf_agents/agents/ppo/ppo_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,15 @@ def compute_advantages(
advantages: Tensor of length (len(rewards) - 1), because the final
timestep is just used for next-step value prediction.
"""
# Arg value_preds was appended with final next_step value. Make tensors
# next_value_preds by stripping first and last elements respectively.
# Arg value_preds was appended with final next_step value. Extract the
# final value before stripping to get the correct final_value for GAE,
# then strip the last element to get the values sequence.
final_value_preds = value_preds[:, -1]
value_preds = value_preds[:, :-1]
if self._use_gae:
advantages = value_ops.generalized_advantage_estimation(
values=value_preds,
final_value=value_preds[:, -1],
final_value=final_value_preds,
rewards=rewards,
discounts=discounts,
td_lambda=self._lambda,
Expand Down
Loading