Skip to main content

PolicyLearner

Trait PolicyLearner 

pub trait PolicyLearner{
    type TrainContext;
    type InnerPolicy: Policy
       where <Self::InnerPolicy as Policy>::Observation: Clone + Batchable,
             <Self::InnerPolicy as Policy>::ActionDistribution: Clone + Batchable,
             <Self::InnerPolicy as Policy>::Action: Clone + Batchable;
    type Record;

    // Required methods
    fn train(
        &mut self,
        input: TransitionBatch<<Self::InnerPolicy as Policy>::Observation, <Self::InnerPolicy as Policy>::Action>,
    ) -> RLTrainOutput<Self::TrainContext, <Self::InnerPolicy as Policy>::PolicyState>;
    fn policy(&self) -> Self::InnerPolicy;
    fn update_policy(&mut self, update: Self::InnerPolicy);
    fn record(&self) -> Self::Record;
    fn load_record(self, record: Self::Record) -> Self;
    fn device(&self) -> Device;
}
Expand description

Learner for a policy.

Required Associated Types§

type TrainContext

Additional context of a training step.

type InnerPolicy: Policy where <Self::InnerPolicy as Policy>::Observation: Clone + Batchable, <Self::InnerPolicy as Policy>::ActionDistribution: Clone + Batchable, <Self::InnerPolicy as Policy>::Action: Clone + Batchable

The policy to train.

type Record

The record of the learner.

Required Methods§

fn train( &mut self, input: TransitionBatch<<Self::InnerPolicy as Policy>::Observation, <Self::InnerPolicy as Policy>::Action>, ) -> RLTrainOutput<Self::TrainContext, <Self::InnerPolicy as Policy>::PolicyState>

Execute a training step on the policy.

fn policy(&self) -> Self::InnerPolicy

Returns the learner’s current policy for validation.

fn update_policy(&mut self, update: Self::InnerPolicy)

Update the learner’s policy.

fn record(&self) -> Self::Record

Convert the learner’s state into a record.

fn load_record(self, record: Self::Record) -> Self

Load the learner’s state from a record.

fn device(&self) -> Device

Returns the device used for training.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§