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 net = 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 net = 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 net = NeuralNet::default(layers); let w = &net.get_net_weights(2); // We add a bias term to the weight matrix assert_eq!(w.rows(), 4); assert_eq!(w.cols(), 3);
Trait Implementations
impl<'a, T: Criterion> Optimizable for NeuralNet<'a, T>[src]
type Inputs = Matrix<f64>
The input data type to the model.
type Targets = Matrix<f64>
The target data type to the model.
fn compute_grad(&self, params: &[f64], inputs: &Matrix<f64>, targets: &Matrix<f64>) -> (f64, Vec<f64>)
Compute the gradient of the neural network.