pub struct GaussianActor<P>where
P: SubModel1<Output = (Tensor, Tensor)>,
P::Config: DeserializeOwned + Serialize + OutDim + Clone,{ /* private fields */ }Expand description
Actor with Gaussian policy.
Implementations§
Source§impl<P> GaussianActor<P>
impl<P> GaussianActor<P>
Sourcepub fn build(
config: GaussianActorConfig<P::Config>,
device: Device,
) -> Result<GaussianActor<P>>
pub fn build( config: GaussianActorConfig<P::Config>, device: Device, ) -> Result<GaussianActor<P>>
Constructs GaussianActor.
Sourcepub fn forward(&self, x: &P::Input) -> (Tensor, Tensor)
pub fn forward(&self, x: &P::Input) -> (Tensor, Tensor)
Returns the parameters of Gaussian distribution given an observation.
The type of return values is (Tensor, Tensor).
The shape of the both tensors is (batch_size, action_dimension).
Sourcepub fn logp<'a>(&self, obs: &P::Input, act: &Tensor) -> Result<Tensor>
pub fn logp<'a>(&self, obs: &P::Input, act: &Tensor) -> Result<Tensor>
Rerurns the log probabilities (densities) of the given actions
Sourcepub fn sample(&mut self, obs: &P::Input, train: bool) -> Result<Tensor>
pub fn sample(&mut self, obs: &P::Input, train: bool) -> Result<Tensor>
Samples actions.
If train is true, actions are sampled from a Gaussian distribution.
Otherwise, the mean of the Gaussian distribution is returned.
pub fn backward_step(&mut self, loss: &Tensor) -> Result<()>
Trait Implementations§
Source§impl<P> Clone for GaussianActor<P>
impl<P> Clone for GaussianActor<P>
Auto Trait Implementations§
impl<P> Freeze for GaussianActor<P>
impl<P> !RefUnwindSafe for GaussianActor<P>
impl<P> Send for GaussianActor<P>
impl<P> Sync for GaussianActor<P>
impl<P> Unpin for GaussianActor<P>
impl<P> !UnwindSafe for GaussianActor<P>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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