Class that validates and converts other data types to N-step Transition.

Note that validation and conversion allows values to contain dictionaries with extra keys as compared to the the specs in the data context. These additional entries / observations are ignored and dropped during conversion.

This non-strict checking allows users to provide additional info and observation keys at input without having to manually prune them before converting.

data_context An instance of DataContext, typically accessed from the TFAgent.data_context property.
gamma A floating point scalar; the discount factor.
n (Optional.) The expected number of frames given a Trajectory input. Given a Trajectory with tensors shaped [B, T, ...], we ensure that T = n + 1. Only used for validation.



View source

Convert value to an N-step Transition; validate data & prune.

  • If value is already a Transition, only validation is performed.
  • If value is a Trajectory with tensors containing a time dimension having T != n + 1, a ValueError is raised.

value A Trajectory or Transition object to convert.

A validated and pruned Transition. If squeeze_time_dim = True, the resulting Transition has tensors with shape [B, ...]. Otherwise, the tensors will have shape [B, T - 1, ...].

TypeError If value is not one of Trajectory or Transition.
ValueError If value has structure that doesn't match the converter's spec.
TypeError If value has a structure that doesn't match the converter's spec.
ValueError If n != None and value is a Trajectory with a time dimension having value other than T=n + 1.