pub struct PPOConfig {
pub learning_rate: f64,
pub n_epochs: usize,
pub batch_size: usize,
pub gamma: f64,
pub gae_lambda: f64,
pub clip_range: f64,
pub clip_range_vf: f64,
pub vf_coef: f64,
pub ent_coef: f64,
pub max_grad_norm: f64,
pub target_kl: f64,
pub seed: u64,
}Expand description
PPO configuration parameters
These hyperparameters control the PPO training process. Default values are based on common settings that work well for simple environments like CartPole.
Fields§
§learning_rate: f64Learning rate for policy and value function
n_epochs: usizeNumber of training epochs per rollout
batch_size: usizeMinibatch size for training
gamma: f64Discount factor (gamma)
gae_lambda: f64GAE lambda parameter
clip_range: f64PPO clipping parameter (epsilon)
clip_range_vf: f64Value function clipping parameter
vf_coef: f64Value function loss coefficient
ent_coef: f64Entropy bonus coefficient
max_grad_norm: f64Maximum gradient norm for clipping.
Applied by both
PPOTrainerBurn and
RecurrentPPOTrainer
as a global L2-norm clip (see
clip_grads_by_global_norm)
over the concatenation of every parameter’s gradient, immediately
before each optimizer step (issue #299; prior to that fix the field
was silently ignored by both trainers). Must be positive —
validate rejects non-positive values — so to
effectively disable clipping set a very large cap (e.g. 1e9).
target_kl: f64Target KL divergence for early stopping
seed: u64Seed for the inner-loop RNG used to shuffle minibatch indices.
Plumbed through the trainer so that two trainers built with the
same seed produce bit-identical updates on the same rollout
(issue #109). The PPO trainer constructs an internal
StdRng::seed_from_u64(seed) at new() time and uses it for
every minibatch shuffle.
Implementations§
Source§impl PPOConfig
impl PPOConfig
Sourcepub fn learning_rate(self, lr: f64) -> Self
pub fn learning_rate(self, lr: f64) -> Self
Set learning rate
Sourcepub fn batch_size(self, size: usize) -> Self
pub fn batch_size(self, size: usize) -> Self
Set minibatch size
Sourcepub fn gae_lambda(self, lambda: f64) -> Self
pub fn gae_lambda(self, lambda: f64) -> Self
Set GAE lambda
Sourcepub fn clip_range(self, clip: f64) -> Self
pub fn clip_range(self, clip: f64) -> Self
Set PPO clipping parameter
Sourcepub fn clip_range_vf(self, clip: f64) -> Self
pub fn clip_range_vf(self, clip: f64) -> Self
Set value function clipping parameter
Sourcepub fn max_grad_norm(self, norm: f64) -> Self
pub fn max_grad_norm(self, norm: f64) -> Self
Set maximum gradient norm
Sourcepub fn seed(self, seed: u64) -> Self
pub fn seed(self, seed: u64) -> Self
Set the seed for the inner-loop RNG used for minibatch shuffling.
See PPOConfig::seed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PPOConfig
impl RefUnwindSafe for PPOConfig
impl Send for PPOConfig
impl Sync for PPOConfig
impl Unpin for PPOConfig
impl UnsafeUnpin for PPOConfig
impl UnwindSafe for PPOConfig
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
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>
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>
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