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) -> Self
pub fn new(input_size: usize, hidden_size: usize, output_size: usize) -> 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 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 set_activation_function(
&mut self,
activation_function: fn(&Matrix) -> Matrix,
activation_function_derivative: fn(&Matrix) -> Matrix,
)
pub fn set_activation_function( &mut self, activation_function: fn(&Matrix) -> Matrix, activation_function_derivative: fn(&Matrix) -> Matrix, )
Sets the activation function for the neural network.
pub fn set_linear_activation(&mut self)
pub fn set_sigmoid_activation(&mut self)
pub fn set_tanh_activation(&mut self)
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.
Trait Implementations§
Source§impl Clone for NeuralNetwork
impl Clone for NeuralNetwork
Source§fn clone(&self) -> NeuralNetwork
fn clone(&self) -> NeuralNetwork
Returns a copy 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 moreAuto 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