tf_agents.agents.data_converter.AsNStepTransition
Stay organized with collections
Save and categorize content based on your preferences.
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 .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-26 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-04-26 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[]]