Class that validates and converts other data types to N-step Transition.
tf_agents.agents.data_converter.AsNStepTransition(
data_context: tf_agents.agents.data_converter.DataContext
,
gamma: tf_agents.typing.types.Float
,
n: typing.Optional[int] = None
)
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.
Args |
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.
|
Methods
__call__
View source
__call__(
value: typing.Any
) -> tf_agents.trajectories.Transition
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.
Args |
value
|
A Trajectory or Transition object to convert.
|
Returns |
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, ...] .
|
Raises |
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 .
|