pub struct AdamW { /* private fields */ }Expand description
AdamW optimizer.
§Attributes
learning_rate- The learning rate of the optimizer.beta1- The beta1 of the optimizer.beta2- The beta2 of the optimizer.epsilon- The epsilon of the optimizer.decay- The decay of the optimizer.velocity- The velocity of the optimizer.momentum- The momentum of the optimizer.
Implementations§
Source§impl AdamW
impl AdamW
Sourcepub fn create(
learning_rate: f32,
beta1: f32,
beta2: f32,
epsilon: f32,
decay: f32,
) -> Optimizer
pub fn create( learning_rate: f32, beta1: f32, beta2: f32, epsilon: f32, decay: f32, ) -> Optimizer
Creates a new AdamW optimizer.
§Default values
learning_rate- 0.001beta1- 0.9beta2- 0.999epsilon- 1e-8decay- 0.01
Sourcepub fn update(
&mut self,
layer: usize,
filter: usize,
bias: bool,
stepnr: i32,
values: &mut Tensor,
gradients: &mut Tensor,
)
pub fn update( &mut self, layer: usize, filter: usize, bias: bool, stepnr: i32, values: &mut Tensor, gradients: &mut Tensor, )
Updates the weights of the layer. Source.
§Function
weights (values) -= learning_rate * decay * valuesmomentum = beta1 * momentum + (1 - beta1) * gradientsvelocity = beta2 * velocity + (1 - beta2) * gradients^2m = momentum / (1 - beta1^stepnr)v = velocity / (1 - beta2^stepnr)weights (values) -= learning_rate * m / (v.sqrt() + epsilon)
§Arguments
layer- The layer of the network.filter- The filter of the layer. Always 0 if the layer is not a convolutional layer.bias- The bias of the layer.stepnr- The step number of the optimizer.values- The weights of the layer.gradients- The gradients of the layer.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AdamW
impl RefUnwindSafe for AdamW
impl Send for AdamW
impl Sync for AdamW
impl Unpin for AdamW
impl UnwindSafe for AdamW
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> 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