Struct border::agent::tch::sac::base::SAC[][src]

pub struct SAC<E, Q, P, O, A> where
    E: Env,
    Q: SubModel2<Output = Tensor>,
    P: SubModel<Output = (Tensor, Tensor)>,
    O: TchBuffer<Item = E::Obs>,
    A: TchBuffer<Item = E::Act>, 
{ /* fields omitted */ }
Expand description

Soft actor critic agent.

Trait Implementations

impl<E, Q, P, O, A> Agent<E> for SAC<E, Q, P, O, A> where
    E: Env,
    Q: SubModel2<Input1 = O::SubBatch, Input2 = A::SubBatch, Output = Tensor>,
    P: SubModel<Input = O::SubBatch, Output = (Tensor, Tensor)>,
    E::Obs: Into<O::SubBatch>,
    E::Act: From<Tensor>,
    O: TchBuffer<Item = E::Obs>,
    A: TchBuffer<Item = E::Act, SubBatch = Tensor>, 
[src]

fn observe(&mut self, step: Step<E>) -> Option<Record>[src]

Update model parameters.

When the return value is Some(Record), it includes:

  • loss_critic: Loss of critic
  • loss_actor: Loss of actor

fn train(&mut self)[src]

Set the policy to training mode.

fn eval(&mut self)[src]

Set the policy to evaluation mode.

fn is_train(&self) -> bool[src]

Return if it is in training mode.

fn push_obs(&self, obs: &E::Obs)[src]

Push observation to the agent. This method is used when resetting the environment. Read more

fn save<T: AsRef<Path>>(&self, path: T) -> Result<(), Box<dyn Error>>[src]

Save the agent in the given directory. This method commonly creates a number of files consisting the agent into the given directory. For example, [crate::agent::tch::dqn::DQN] agent saves two Q-networks corresponding to the original and target networks. Read more

fn load<T: AsRef<Path>>(&mut self, path: T) -> Result<(), Box<dyn Error>>[src]

Load the agent from the given directory.

impl<E, Q, P, O, A> Policy<E> for SAC<E, Q, P, O, A> where
    E: Env,
    Q: SubModel2<Input1 = O::SubBatch, Input2 = A::SubBatch, Output = Tensor>,
    P: SubModel<Input = O::SubBatch, Output = (Tensor, Tensor)>,
    E::Obs: Into<O::SubBatch>,
    E::Act: From<Tensor>,
    O: TchBuffer<Item = E::Obs>,
    A: TchBuffer<Item = E::Act, SubBatch = Tensor>, 
[src]

fn sample(&mut self, obs: &E::Obs) -> E::Act[src]

Sample an action given an observation.

Auto Trait Implementations

impl<E, Q, P, O, A> !RefUnwindSafe for SAC<E, Q, P, O, A>

impl<E, Q, P, O, A> Send for SAC<E, Q, P, O, A> where
    A: Send,
    E: Send,
    O: Send,
    P: Send,
    Q: Send,
    <E as Env>::Obs: Send

impl<E, Q, P, O, A> !Sync for SAC<E, Q, P, O, A>

impl<E, Q, P, O, A> Unpin for SAC<E, Q, P, O, A> where
    A: Unpin,
    E: Unpin,
    O: Unpin,
    P: Unpin,
    Q: Unpin,
    <E as Env>::Obs: Unpin

impl<E, Q, P, O, A> UnwindSafe for SAC<E, Q, P, O, A> where
    A: UnwindSafe,
    E: UnwindSafe,
    O: UnwindSafe,
    P: UnwindSafe,
    Q: UnwindSafe,
    <E as Env>::Obs: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

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

pub fn vzip(self) -> V