pub struct Bc<E, P, R>where
P: SubModel1<Output = Tensor>,
P::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone,{ /* private fields */ }Expand description
Behavior cloning (BC) agent implemented with candle.
P is the type parameter of the policy model.
Trait Implementations§
Source§impl<E, P, R> Agent<E, R> for Bc<E, P, R>where
E: Env,
P: SubModel1<Output = Tensor>,
R: ReplayBufferBase,
E::Obs: Into<P::Input>,
E::Act: From<P::Output>,
P::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone,
R::Batch: TransitionBatch,
<R::Batch as TransitionBatch>::ObsBatch: Into<P::Input>,
<R::Batch as TransitionBatch>::ActBatch: Into<Tensor>,
impl<E, P, R> Agent<E, R> for Bc<E, P, R>where
E: Env,
P: SubModel1<Output = Tensor>,
R: ReplayBufferBase,
E::Obs: Into<P::Input>,
E::Act: From<P::Output>,
P::Config: DeserializeOwned + Serialize + OutDim + Debug + PartialEq + Clone,
R::Batch: TransitionBatch,
<R::Batch as TransitionBatch>::ObsBatch: Into<P::Input>,
<R::Batch as TransitionBatch>::ActBatch: Into<Tensor>,
Source§fn save_params(&self, path: &Path) -> Result<Vec<PathBuf>>
fn save_params(&self, path: &Path) -> Result<Vec<PathBuf>>
Save model parameters in the given directory.
The parameters of the policy_model are saved as policy_model.pt.
Source§fn load_params(&mut self, path: &Path) -> Result<()>
fn load_params(&mut self, path: &Path) -> Result<()>
Load model parameters in the given directory.
The parameters of the policy_model are loaded from policy_model.pt.
Source§fn opt(&mut self, buffer: &mut R)
fn opt(&mut self, buffer: &mut R)
Performs a single optimization step using experiences from the replay buffer. Read more
Source§fn opt_with_record(&mut self, buffer: &mut R) -> Record
fn opt_with_record(&mut self, buffer: &mut R) -> Record
Performs an optimization step and returns training metrics. Read more
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Returns a reference to the agent as a type-erased
Any value. Read moreSource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Returns a mutable reference to the agent as a type-erased
Any value. Read moreSource§impl<E, P, R> Configurable for Bc<E, P, R>
impl<E, P, R> Configurable for Bc<E, P, R>
Source§impl<E, P, R> Policy<E> for Bc<E, P, R>
impl<E, P, R> Policy<E> for Bc<E, P, R>
Source§fn sample(&mut self, obs: &E::Obs) -> E::Act
fn sample(&mut self, obs: &E::Obs) -> E::Act
Sample an action.
When action_type is set to BcActionType::Discrete, this method returns the action
corresponding to the argmax of the policy model’s output tensor.
On the other hand, when action_type is set to BcActionType::Continuous, this method
returns the output tensor as is.
Auto Trait Implementations§
impl<E, P, R> Freeze for Bc<E, P, R>
impl<E, P, R> !RefUnwindSafe for Bc<E, P, R>
impl<E, P, R> Send for Bc<E, P, R>
impl<E, P, R> Sync for Bc<E, P, R>
impl<E, P, R> Unpin for Bc<E, P, R>
impl<E, P, R> !UnwindSafe for Bc<E, P, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more