pub struct NeuralNetwork { /* private fields */ }
Expand description
A simple feedforward neural network with one hidden layer.
Implementations§
Source§impl NeuralNetwork
impl NeuralNetwork
Sourcepub fn new(
input_size: usize,
hidden_size: usize,
output_size: usize,
rng: Option<&mut StdRng>,
) -> Self
pub fn new( input_size: usize, hidden_size: usize, output_size: usize, rng: Option<&mut StdRng>, ) -> Self
Creates a new neural network with the given sizes for input, hidden, and output layers. The weights and biases are initialized randomly.
Sourcepub fn learning_rate(&self) -> f64
pub fn learning_rate(&self) -> f64
Returns the learning rate of the neural network.
Sourcepub fn set_learning_rate(&mut self, learning_rate: f64)
pub fn set_learning_rate(&mut self, learning_rate: f64)
Sets the learning rate for the neural network.
Sourcepub fn activation_function(&self) -> &ActivationFunction
pub fn activation_function(&self) -> &ActivationFunction
Returns the activation function of the neural network.
Sourcepub fn set_activation_function(
&mut self,
activation_function: ActivationFunction,
)
pub fn set_activation_function( &mut self, activation_function: ActivationFunction, )
Sets the activation function for the neural network.
Sourcepub fn predict(&self, input: Vec<f64>) -> Vec<f64>
pub fn predict(&self, input: Vec<f64>) -> Vec<f64>
Predicts the output for the given input using the neural network.
Sourcepub fn train(&mut self, input: Vec<f64>, target: Vec<f64>)
pub fn train(&mut self, input: Vec<f64>, target: Vec<f64>)
Trains the neural network using the given input and target output. The input and target should be vectors of the same length as the input and output sizes of the network. The training process involves forward propagation and backpropagation to adjust the weights and biases.
pub fn mutate(&mut self, rng: &mut StdRng, mutation_rate: f64)
Trait Implementations§
Source§impl Clone for NeuralNetwork
impl Clone for NeuralNetwork
Source§fn clone(&self) -> NeuralNetwork
fn clone(&self) -> NeuralNetwork
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for NeuralNetwork
impl Debug for NeuralNetwork
Source§impl Default for NeuralNetwork
impl Default for NeuralNetwork
Source§fn default() -> NeuralNetwork
fn default() -> NeuralNetwork
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for NeuralNetwork
impl<'de> Deserialize<'de> for NeuralNetwork
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for NeuralNetwork
impl RefUnwindSafe for NeuralNetwork
impl Send for NeuralNetwork
impl Sync for NeuralNetwork
impl Unpin for NeuralNetwork
impl UnwindSafe for NeuralNetwork
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