View source on GitHub |
Stateful observer for writing fixed length trajectories to Reverb.
tf_agents.replay_buffers.ReverbAddTrajectoryObserver(
py_client: tf_agents.typing.types.ReverbClient
,
table_name: Union[Text, Sequence[Text]],
sequence_length: int,
stride_length: int = 1,
priority: Union[float, int] = 1,
pad_end_of_episodes: bool = False,
tile_end_of_episodes: bool = False
)
Used in the notebooks
Used in the tutorials |
---|
This observer should be called at every environment step. It does not support batched trajectories.
Steps are cached until sequence_length
steps are gathered. At which point an
item is created. From there on a new item is created every stride_length
observer calls.
If an episode terminates before enough steps are cached, the data is discarded
unless pad_end_of_episodes
is set.
Raises | |
---|---|
ValueError
|
If tile_end_of_episodes is set without
pad_end_of_episodes .
|
Attributes | |
---|---|
py_client
|
Methods
close
close() -> None
Closes the writer of the observer.
flush
flush()
Ensures that items are pushed to the service.
get_table_signature
get_table_signature()
open
open() -> None
Open the writer of the observer.
reset
reset(
write_cached_steps: bool = True
) -> None
Resets the state of the observer.
Args | |
---|---|
write_cached_steps
|
boolean flag indicating whether we want to write the cached trajectory. When this argument is True, the function attempts to write the cached data before resetting (optionally with padding). Otherwise, the cached data gets dropped. |
__call__
__call__(
trajectory: tf_agents.trajectories.Trajectory
) -> None
Writes the trajectory into the underlying replay buffer.
Allows trajectory to be a flattened trajectory. No batch dimension allowed.
Args | |
---|---|
trajectory
|
The trajectory to be written which could be (possibly nested) trajectory object or a flattened version of a trajectory. It assumes there is no batch dimension. |