Cogent

Introduction

Cogent is a very basic library for training basic neural networks for classification tasks. It is designed to be as simple as feasible. Hyperparameters in neural network training can be set automatically, so why not? Ideally you could simply do: rust let net = NeuralNetwork::Train(&data); This is the most basic and not quite there yet implementation of that idea.

Training a network to classify MNIST: ```rust // Setup // ---------- // 784-Sigmoid->100-Softmax->10 let mut neural_network = NeuralNetwork::new(784,&[ Layer::Dense(800,Activation::ReLU), Layer::Dense(10,Activation::Softmax) ]);

// Setting training and testing data // get_mnist_dataset(bool) simply gets MNIST data in format of Vec<(Vec<f32>,usize)> where each entry is an example (tuple.0=input and tuple.1=class). // The boolean specifies if it is the MNIST testing data (true) or training data (false).

let trainingdata:Vec<(Vec,usize)> = getmnistdataset(false); let testingdata:Vec<(Vec,usize)> = getmnistdataset(true);

// Execution // ---------- // Trains until no notable accuracy improvements are being made over a number of iterations. // By default this would end training if 0.5% accuracy improvement was not seen over 6 iterations (often referred to as 'epochs').

neuralnetwork.train(&trainingdata) .evaluationdata(EvaluationData::Actual(&testingdata)) .l2(0.1f32) .go();

// .evaluation_data(...) sets the evaluation data. // If evaluation data is not set it will simply shuffle and split off a random group from training data to be evaluation data. // In the case of MNIST where training and evaluation datasets are given seperately, it makes sense to set it as such. // .l2(...) sets the lambda value for L2 regularisation.

// Evaluation // ---------- let (cost,correctlyclassified):(f32,u32) = neuralnetwork.evaluate(&testingdata,None); // (cost,examples correctly classified) println!("Cost: {:.2}",cost); println!( "Accuracy: {}/{} ({:.2}%)", correctlyclassified, testingdata.len(), correctlyclassified as f32 / testing_data.len() as f32 ); ```

While a huge amount of my work has gone into making this and learning the basics of neural networks along the way, I am immensely (and I cannot stress this enough) amateur in inumerable ways.

If you find any issues I would really appreciate if you could let me know (and possibly suggest any solutions).

Features

Installation

  1. Setup ArrayFire Rust bindings (Ignore step 4).
  2. Add cogent = "^0.4" to Cargo.toml.

TODO

Task types:

Tasks:

  1. :ballotboxwith_check: Convolutional layers.
  2. :ballotboxwith_check: Meticulous testing (making sure things work).
  3. :ballotboxwith_check: Optimise usage of VRAM.
  4. :ballotboxwith_check: Automatic net creation and layer setting from given dataset.
  5. :ballotboxwith_check: Meticulous benchmarking (making sure things are fast).
  6. :ballotboxwith_check: Benchmarking against other popular neural network libraries (TensorFlow etc.)
  7. :repeat: Improve defaults.
  8. :repeat: Learn more.

Please note that things may not be developed inorder, it is only my estimation.