pub struct NeuralNet<T>{
pub layers: Vec<Box<dyn Layer<T>>>,
pub loss_fn: Box<dyn LossFunction<NeuralNetDataType, T>>,
pub parameter_count: u64,
pub label: String,
pub name: String,
/* private fields */
}Expand description
Feed-forward neural network container.
Holds an ordered list of Layer trait objects, the configured loss
function, and training metadata (parameter count, name/label, and
learning state). Instances are used to predict, fit, and
save_model.
Fields§
§layers: Vec<Box<dyn Layer<T>>>§loss_fn: Box<dyn LossFunction<NeuralNetDataType, T>>§parameter_count: u64§label: String§name: StringImplementations§
Source§impl<T> NeuralNet<T>
impl<T> NeuralNet<T>
pub fn new( layers: Vec<Box<dyn Layer<T>>>, loss_fn: Box<dyn LossFunction<NeuralNetDataType, T>>, param_count: u64, label: String, name: String, current_epoch: usize, current_lr: NeuralNetDataType, ) -> Self
Sourcepub fn add(&mut self, layer: Box<dyn Layer<T>>)
pub fn add(&mut self, layer: Box<dyn Layer<T>>)
Append a layer to the network.
The provided box must implement the Layer trait for the network’s
tensor type T.
Sourcepub fn predict(&mut self, input: &T) -> Result<T, String>
pub fn predict(&mut self, input: &T) -> Result<T, String>
Run a forward pass and return the network output for input.
pub fn fit<F>( &mut self, x_train: &T, y_train: &T, epochs: usize, epoch_offset: usize, base_lr: NeuralNetDataType, lr_adjustment: bool, hook: F, hook_interval: usize, ) -> Result<(), String>
Sourcepub fn save_model(&self, filepath: &str)
pub fn save_model(&self, filepath: &str)
Serialize and write the model weights and metadata to filepath.
Auto Trait Implementations§
impl<T> Freeze for NeuralNet<T>
impl<T> !RefUnwindSafe for NeuralNet<T>
impl<T> !Send for NeuralNet<T>
impl<T> !Sync for NeuralNet<T>
impl<T> Unpin for NeuralNet<T>
impl<T> !UnwindSafe for NeuralNet<T>
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