Skip to content

Commit

Permalink
Workaround for epsilon_greedy_policy assuming info_spec is a named tu…
Browse files Browse the repository at this point in the history
…ple.

Only do _replace if info_fields_to_inherit_from_greedy is set.

PiperOrigin-RevId: 390752961
Change-Id: I9b925b5140fc4fc4cac8edcd2dab9ada6592369b
  • Loading branch information
Oscar Ramirez authored and Copybara-Service committed Aug 14, 2021
1 parent b9a0458 commit b95f033
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tf_agents/policies/epsilon_greedy_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,14 @@ def _action(self, time_step, policy_state, seed):
info.bandit_policy_type, mask=random_policy_mask) # pytype: disable=attribute-error
info = policy_utilities.set_bandit_policy_type(
info, bandit_policy_type)
info = info._replace(
**{
f: getattr(greedy_action.info, f)
for f in self.info_fields_to_inherit_from_greedy
})

# TODO(b/196644931): Should not assume info is a named tuple.
if self.info_fields_to_inherit_from_greedy:
info = info._replace(
**{
f: getattr(greedy_action.info, f)
for f in self.info_fields_to_inherit_from_greedy
})
else:
if random_action.info:
raise ValueError('Incompatible info field')
Expand Down

0 comments on commit b95f033

Please sign in to comment.