Struct AsyncTrainer

Source
pub struct AsyncTrainer<A, E, R>
where A: Agent<E, R> + Configurable + SyncModel, E: Env, R: ExperienceBufferBase + ReplayBufferBase, R::Item: Send + 'static,
{ /* private fields */ }
Expand description

Manages asynchronous training loop in a single machine.

It interacts with ActorManager as shown below:

flowchart LR subgraph ActorManager E[Actor]-->|ReplayBufferBase::PushedItem|H[ReplayBufferProxy] F[Actor]-->H G[Actor]-->H end K-->|SyncModel::ModelInfo|E K-->|SyncModel::ModelInfo|F K-->|SyncModel::ModelInfo|G subgraph I[AsyncTrainer] H-->|PushedItemMessage|J[ReplayBuffer] J-->|ReplayBufferBase::Batch|K[Agent] end

Implementations§

Source§

impl<A, E, R> AsyncTrainer<A, E, R>
where A: Agent<E, R> + Configurable + SyncModel + 'static, E: Env, R: ExperienceBufferBase + ReplayBufferBase, R::Item: Send + 'static,

Source

pub fn build( config: &AsyncTrainerConfig, agent_config: &A::Config, env_config: &E::Config, replay_buffer_config: &R::Config, r_bulk_pushed_item: Receiver<PushedItemMessage<R::Item>>, model_info_sender: Sender<(usize, A::ModelInfo)>, stop: Arc<Mutex<bool>>, ) -> Self

Creates AsyncTrainer.

Source

pub fn train<D>( &mut self, recorder: &mut Box<dyn Recorder<E, R>>, evaluator: &mut D, guard_init_env: Arc<Mutex<bool>>, ) -> AsyncTrainStat
where D: Evaluator<E>,

Runs training loop.

In the training loop, the following values will be pushed into the given recorder:

  • samples_total - Total number of samples pushed into the replay buffer. Here, a “sample” is an item in ExperienceBufferBase::Item.
  • opt_steps_per_sec - The number of optimization steps per second.
  • samples_per_sec - The number of samples per second.
  • samples_per_opt_steps - The number of samples per optimization step.

These values will typically be monitored with tensorboard.

Auto Trait Implementations§

§

impl<A, E, R> Freeze for AsyncTrainer<A, E, R>

§

impl<A, E, R> RefUnwindSafe for AsyncTrainer<A, E, R>

§

impl<A, E, R> Send for AsyncTrainer<A, E, R>
where <E as Env>::Config: Send, <R as ReplayBufferBase>::Config: Send, <A as Configurable>::Config: Send, <A as SyncModel>::ModelInfo: Send, A: Send, E: Send, R: Send,

§

impl<A, E, R> Sync for AsyncTrainer<A, E, R>
where <E as Env>::Config: Sync, <R as ReplayBufferBase>::Config: Sync, <A as Configurable>::Config: Sync, <A as SyncModel>::ModelInfo: Send, A: Sync, E: Sync, R: Sync,

§

impl<A, E, R> Unpin for AsyncTrainer<A, E, R>
where <E as Env>::Config: Unpin, <R as ReplayBufferBase>::Config: Unpin, <A as Configurable>::Config: Unpin, A: Unpin, E: Unpin, R: Unpin, <R as ExperienceBufferBase>::Item: Unpin,

§

impl<A, E, R> UnwindSafe for AsyncTrainer<A, E, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V