pub struct Sampler<E, P>where
E: Env,
P: StepProcessor<E>,{ /* private fields */ }
Expand description
Encapsulates sampling steps. Specifically it does the followint steps:
- Samples an action from the
Agent
, apply to theEnv
and takesStep
. - Convert
Step
into a transition (typically a batch) withStepProcessor
. - Pushes the trainsition to
ReplayBufferBase
. - Count episode length and pushes to
Record
.
TODO: being able to set interval_env_record
Implementations§
Source§impl<E, P> Sampler<E, P>where
E: Env,
P: StepProcessor<E>,
impl<E, P> Sampler<E, P>where
E: Env,
P: StepProcessor<E>,
Sourcepub fn sample_and_push<A, R, R_>(
&mut self,
agent: &mut A,
buffer: &mut R_,
) -> Result<Record>where
A: Agent<E, R>,
R: ExperienceBufferBase<Item = P::Output> + ReplayBufferBase,
R_: ExperienceBufferBase<Item = R::Item>,
pub fn sample_and_push<A, R, R_>(
&mut self,
agent: &mut A,
buffer: &mut R_,
) -> Result<Record>where
A: Agent<E, R>,
R: ExperienceBufferBase<Item = P::Output> + ReplayBufferBase,
R_: ExperienceBufferBase<Item = R::Item>,
Samples transitions and pushes them into the replay buffer.
The replay buffer R_
, to which samples will be pushed, has to accept
Item
that are the same with Agent::R
.
Sourcepub fn fps(&mut self) -> f32
pub fn fps(&mut self) -> f32
Returns frames (environment steps) per second, then resets the internal counter.
A frame involves taking action, applying it to the environment, producing transition, and pushing it into the replay buffer.
Sourcepub fn reset_fps_counter(&mut self)
pub fn reset_fps_counter(&mut self)
Reset stats for computing FPS.
Auto Trait Implementations§
impl<E, P> Freeze for Sampler<E, P>
impl<E, P> RefUnwindSafe for Sampler<E, P>
impl<E, P> Send for Sampler<E, P>
impl<E, P> Sync for Sampler<E, P>
impl<E, P> Unpin for Sampler<E, P>
impl<E, P> UnwindSafe for Sampler<E, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more