pub struct GpuTrainer {
pub net: GpuNeuralNet,
pub backprop: BackpropGpu,
pub learning_rate: f64,
pub optimizer: OptimizerType,
pub adam: Option<AdamOptimizer>,
}Expand description
Combines a network, a backprop context, and an optimiser for training.
Fields§
§net: GpuNeuralNetNeural network being trained.
backprop: BackpropGpuBackpropagation state.
learning_rate: f64Learning rate.
optimizer: OptimizerTypeWhich optimiser to use.
adam: Option<AdamOptimizer>Adam optimiser instance (only active when optimizer == Adam).
Implementations§
Source§impl GpuTrainer
impl GpuTrainer
Sourcepub fn new(
net: GpuNeuralNet,
learning_rate: f64,
optimizer: OptimizerType,
) -> Self
pub fn new( net: GpuNeuralNet, learning_rate: f64, optimizer: OptimizerType, ) -> Self
Create a new trainer wrapping net with the given optimiser.
Sourcepub fn train_step(&mut self, input: &[f64], target: &[f64]) -> f64
pub fn train_step(&mut self, input: &[f64], target: &[f64]) -> f64
Execute one training step: forward pass → loss → backward → update.
input— network input.target— ground-truth target.
Returns the MSE loss before the update.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GpuTrainer
impl RefUnwindSafe for GpuTrainer
impl Send for GpuTrainer
impl Sync for GpuTrainer
impl Unpin for GpuTrainer
impl UnsafeUnpin for GpuTrainer
impl UnwindSafe for GpuTrainer
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