Struct juggernaut::nn::NeuralNetwork
[−]
[src]
pub struct NeuralNetwork { /* fields omitted */ }
Represents a Neural Network with layers, inputs and outputs
Methods
impl NeuralNetwork
[src]
fn new() -> NeuralNetwork
fn on_error<FN>(&mut self, callback_fn: FN) where
FN: 'static + Fn(f64),
FN: 'static + Fn(f64),
To add a callback function and receive the errors of the network during training process Please note that there is another function that basically calcualtes the error value
fn on_epoch<FN>(&mut self, callback_fn: FN) where
FN: 'static + Fn(&NeuralNetwork),
FN: 'static + Fn(&NeuralNetwork),
To add a callback function to get called after each epoch
fn add_layer(&mut self, layer: NeuralLayer)
To add a new layer to the network
Example:
use juggernaut::sample::Sample; use juggernaut::nl::NeuralLayer; use juggernaut::nn::NeuralNetwork; use juggernaut::activation::Activation; use juggernaut::activation::Sigmoid; let mut test = NeuralNetwork::new(); // 1st layer = 4 neurons - 2 inputs let nl1 = NeuralLayer::new(4, 2, Sigmoid::new()); test.add_layer(nl1);
fn get_layers(&self) -> &Vec<NeuralLayer>
To get the layers of the network
fn forward(&self, samples: &Vec<Sample>) -> Vec<Matrix>
This is the forward method of the network which calculates the random weights and multiplies the inputs of given samples to the weights matrix. Thinks.
fn evaluate(&self, sample: Sample) -> Matrix
Use this function to evaluate a trained neural network
This function simply passes the given sample to the forward
function and returns the
output of last layer