pub struct REINFORCEAgent { /* private fields */ }Expand description
REINFORCE (Policy Gradient) agent
Implementations§
Source§impl REINFORCEAgent
impl REINFORCEAgent
Sourcepub fn new(
state_dim: usize,
action_dim: usize,
hidden_dim: usize,
gamma: f32,
learning_rate: f32,
) -> Self
pub fn new( state_dim: usize, action_dim: usize, hidden_dim: usize, gamma: f32, learning_rate: f32, ) -> Self
Create a new REINFORCE agent
Sourcepub fn select_action(&self, state: &Tensor) -> usize
pub fn select_action(&self, state: &Tensor) -> usize
Select action from policy
Sourcepub fn store_step(&mut self, state: Tensor, action: usize, reward: f32)
pub fn store_step(&mut self, state: Tensor, action: usize, reward: f32)
Store step in current episode
Sourcepub fn train_episode(&mut self) -> f32
pub fn train_episode(&mut self) -> f32
Train on completed episode
Auto Trait Implementations§
impl Freeze for REINFORCEAgent
impl !RefUnwindSafe for REINFORCEAgent
impl Send for REINFORCEAgent
impl Sync for REINFORCEAgent
impl Unpin for REINFORCEAgent
impl !UnwindSafe for REINFORCEAgent
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> 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