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

pub struct NeuralNet<'a, T: Criterion> {
    // some fields omitted
}

Neural Network struct

Methods

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

fn default(layer_sizes: &[usize]) -> NeuralNet<BCECriterion>

Creates a neural network with the specified layer sizes.

Uses the default settings (gradient descent and sigmoid activation function).

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::default(layers);

impl<'a, T: Criterion> NeuralNet<'a, T>
[src]

fn new(layer_sizes: &[usize], criterion: T) -> NeuralNet<T>

Create a new neural network with the specified layer sizes.

The layer sizes slice should include the input, hidden layers, and output layer sizes. The type of activation function must be specified.

Currently defaults to simple batch Gradient Descent for optimization.

Examples

use rusty_machine::learning::nnet::BCECriterion;
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, BCECriterion);

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::default(layers);

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

Trait Implementations

impl<'a, T: Criterion> Optimizable for NeuralNet<'a, T>
[src]

type Data = Matrix<f64>

The input data type to the model.

type Target = Matrix<f64>

The target data type to the model.

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

Compute the gradient of the neural network.

impl<'a, T: Criterion> SupModel<Matrix<f64>, Matrix<f64>> for NeuralNet<'a, T>
[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.