Trait Agent

Source
pub trait Agent<E: Env, R: ReplayBufferBase>: Policy<E> {
    // Required methods
    fn train(&mut self);
    fn eval(&mut self);
    fn is_train(&self) -> bool;
    fn opt_with_record(&mut self, buffer: &mut R) -> Record;
    fn save_params<T: AsRef<Path>>(&self, path: T) -> Result<()>;
    fn load_params<T: AsRef<Path>>(&mut self, path: T) -> Result<()>;

    // Provided method
    fn opt(&mut self, buffer: &mut R) { ... }
}
Expand description

Represents a trainable policy on an environment.

Required Methods§

Source

fn train(&mut self)

Set the policy to training mode.

Source

fn eval(&mut self)

Set the policy to evaluation mode.

Source

fn is_train(&self) -> bool

Return if it is in training mode.

Source

fn opt_with_record(&mut self, buffer: &mut R) -> Record

Performs an optimization step and returns some information.

Source

fn save_params<T: AsRef<Path>>(&self, path: T) -> Result<()>

Save the parameters of the agent in the given directory. This method commonly creates a number of files consisting the agent in the directory. For example, the DQN agent in border_tch_agent crate saves two Q-networks corresponding to the original and target networks.

Source

fn load_params<T: AsRef<Path>>(&mut self, path: T) -> Result<()>

Load the parameters of the agent from the given directory.

Provided Methods§

Source

fn opt(&mut self, buffer: &mut R)

Performs an optimization step.

buffer is a replay buffer from which transitions will be taken for updating model parameters.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§