pub struct GradientDescent {
pub learning_rate: f64,
pub max_iterations: usize,
pub tolerance: f64,
}Expand description
Gradient Descent optimizer
Fields§
§learning_rate: f64§max_iterations: usize§tolerance: f64Implementations§
Source§impl GradientDescent
impl GradientDescent
Sourcepub fn new(learning_rate: f64, max_iterations: usize) -> Self
pub fn new(learning_rate: f64, max_iterations: usize) -> Self
Examples found in repository?
examples/vqe_h2.rs (line 356)
344fn run_vqe_hardware_efficient_gd(hamiltonian: &PauliObservable, depth: usize) -> VQEResult {
345 println!("\n{}", "=".repeat(70));
346 println!(
347 "Hardware-Efficient Ansatz (depth={}) with Gradient Descent",
348 depth
349 );
350 println!("{}", "=".repeat(70));
351
352 let ansatz =
353 HardwareEfficientAnsatz::new(4, depth, EntanglingGate::CNOT, EntanglingPattern::Linear);
354
355 let gradient_method = ParameterShift::new();
356 let optimizer = GradientDescent::new(0.01, 200).with_tolerance(1e-6);
357
358 let mut vqe = VQE::new(ansatz, hamiltonian.clone(), gradient_method, optimizer);
359 vqe.verbose = true;
360 vqe.run_random()
361}Sourcepub fn with_tolerance(self, tolerance: f64) -> Self
pub fn with_tolerance(self, tolerance: f64) -> Self
Examples found in repository?
examples/vqe_h2.rs (line 356)
344fn run_vqe_hardware_efficient_gd(hamiltonian: &PauliObservable, depth: usize) -> VQEResult {
345 println!("\n{}", "=".repeat(70));
346 println!(
347 "Hardware-Efficient Ansatz (depth={}) with Gradient Descent",
348 depth
349 );
350 println!("{}", "=".repeat(70));
351
352 let ansatz =
353 HardwareEfficientAnsatz::new(4, depth, EntanglingGate::CNOT, EntanglingPattern::Linear);
354
355 let gradient_method = ParameterShift::new();
356 let optimizer = GradientDescent::new(0.01, 200).with_tolerance(1e-6);
357
358 let mut vqe = VQE::new(ansatz, hamiltonian.clone(), gradient_method, optimizer);
359 vqe.verbose = true;
360 vqe.run_random()
361}Trait Implementations§
Auto Trait Implementations§
impl Freeze for GradientDescent
impl RefUnwindSafe for GradientDescent
impl Send for GradientDescent
impl Sync for GradientDescent
impl Unpin for GradientDescent
impl UnsafeUnpin for GradientDescent
impl UnwindSafe for GradientDescent
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.