Struct rusty_machine::learning::nnet::NeuralNet [] [src]

pub struct NeuralNet<'a> {
    pub weights: Vec<f64>,
    // some fields omitted
}

Neural Network struct

Fields

weights: Vec<f64>

Methods

impl<'a> NeuralNet<'a>
[src]

fn new(layer_sizes: &[usize]) -> NeuralNet

Create a new neural network with the specified layer sizes.

The layer sizes slice should include the input, hidden layers, and output layer sizes.

Currently defaults to simple batch Gradient Descent for optimization.

Examples

use rusty_machine::learning::nnet::NeuralNet;

// Create a neural net with 4 layers, 3 neurons in each.
let layers = &[3; 4];
let mut a = NeuralNet::new(layers);

fn get_net_weights(&self, idx: usize) -> Matrix<f64>

Gets matrix of weights between specified layer and forward layer.

Examples

use rusty_machine::learning::nnet::NeuralNet;

// Create a neural net with 4 layers, 3 neurons in each.
let layers = &[3; 4];
let mut a = NeuralNet::new(layers);

let w = &a.get_net_weights(2);
assert_eq!(w.rows(), 4);
assert_eq!(w.cols(), 3);

Trait Implementations

impl<'a> Optimizable for NeuralNet<'a>
[src]

type Data = Matrix<f64>

type Target = Matrix<f64>

fn compute_grad(&self, params: &[f64], data: &Matrix<f64>, target: &Matrix<f64>) -> Vec<f64>

Compute the gradient of the neural network.

impl<'a> SupModel<Matrix<f64>, Matrix<f64>> for NeuralNet<'a>
[src]

fn predict(&self, data: &Matrix<f64>) -> Matrix<f64>

Predict neural network output using forward propagation.

fn train(&mut self, data: &Matrix<f64>, values: &Matrix<f64>)

Train the model using gradient optimization and back propagation.