Struct border_tch_agent::sac::Sac

source ·
pub struct Sac<E, Q, P, R>where
    E: Env,
    Q: SubModel2<Output = Tensor>,
    P: SubModel<Output = (Tensor, Tensor)>,
    R: ReplayBufferBase,
    E::Obs: Into<Q::Input1> + Into<P::Input>,
    E::Act: Into<Q::Input2>,
    Q::Input2: From<Tensor>,
    Q::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone,
    P::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone,
    R::Batch: StdBatchBase,
    <R::Batch as StdBatchBase>::ObsBatch: Into<Q::Input1> + Into<P::Input> + Clone,
    <R::Batch as StdBatchBase>::ActBatch: Into<Q::Input2> + Into<Tensor>,{ /* private fields */ }
Expand description

Soft actor critic (SAC) agent.

Trait Implementations§

source§

impl<E, Q, P, R> Agent<E, R> for Sac<E, Q, P, R>where E: Env, Q: SubModel2<Output = Tensor>, P: SubModel<Output = (Tensor, Tensor)>, R: ReplayBufferBase, E::Obs: Into<Q::Input1> + Into<P::Input>, E::Act: Into<Q::Input2> + From<Tensor>, Q::Input2: From<Tensor>, Q::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone, P::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone, R::Batch: StdBatchBase, <R::Batch as StdBatchBase>::ObsBatch: Into<Q::Input1> + Into<P::Input> + Clone, <R::Batch as StdBatchBase>::ActBatch: Into<Q::Input2> + Into<Tensor>,

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(&mut self, buffer: &mut R) -> Option<Record>

Do an optimization step.
source§

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

Save 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<T: AsRef<Path>>(&mut self, path: T) -> Result<()>

Load the agent from the given directory.
source§

impl<E, Q, P, R> Policy<E> for Sac<E, Q, P, R>where E: Env, Q: SubModel2<Output = Tensor>, P: SubModel<Output = (Tensor, Tensor)>, R: ReplayBufferBase, E::Obs: Into<Q::Input1> + Into<P::Input>, E::Act: Into<Q::Input2> + From<Tensor>, Q::Input2: From<Tensor>, Q::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone, P::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone, R::Batch: StdBatchBase, <R::Batch as StdBatchBase>::ObsBatch: Into<Q::Input1> + Into<P::Input> + Clone, <R::Batch as StdBatchBase>::ActBatch: Into<Q::Input2> + Into<Tensor>,

source§

fn build(config: Self::Config) -> Self

Constructs Sac agent.

§

type Config = SacConfig<Q, P>

Configuration of the policy.
source§

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

Sample an action given an observation.

Auto Trait Implementations§

§

impl<E, Q, P, R> RefUnwindSafe for Sac<E, Q, P, R>where E: RefUnwindSafe, P: RefUnwindSafe, Q: RefUnwindSafe, R: RefUnwindSafe,

§

impl<E, Q, P, R> Send for Sac<E, Q, P, R>where E: Send, P: Send, Q: Send, R: Send,

§

impl<E, Q, P, R> !Sync for Sac<E, Q, P, R>

§

impl<E, Q, P, R> Unpin for Sac<E, Q, P, R>where E: Unpin, P: Unpin, Q: Unpin, R: Unpin,

§

impl<E, Q, P, R> UnwindSafe for Sac<E, Q, P, R>where E: UnwindSafe, P: UnwindSafe, Q: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V