BaseReplayBuffer

class maze.train.trainers.common.replay_buffer.replay_buffer.BaseReplayBuffer

Abstract interface for all replay buffer implementations.

abstract add_rollout(rollout: SpacesTrajectoryRecord | List[StructuredSpacesRecord]) None

Add an actor rollout to the buffer.

Parameters:

rollout – A single actor rollout consisting of n_rollout_steps transitions.

abstract add_transition(transition: StructuredSpacesRecord | SpacesTrajectoryRecord) None

Add a single transition (rollout length == 1) to the buffer.

Parameters:

transition – The actor transition to be added to the buffer.

abstract sample_batch(n_samples: int, learner_device: str) List[StructuredSpacesRecord | SpacesTrajectoryRecord]

Sample mini-batch randomly from the buffer.

Parameters:
  • n_samples – The number of samples to draw.

  • learner_device – The device of the learner (cpu or cuda).

Returns:

A sample batch of trajectory or spaces records