Sunday 30 September 2018

Neural Network Basics

A previous post introduced ojAlgo's Artificial Neural Network feature. It did so by presenting a fully functional program that trained and evaluated a network model to categorise handwritten digits using the MNIST data set. That example then included all necessary pre and post processing as well as code that would generate the actual image (*.png) files. All of that may have obscured just how simple it is to work with ojAlgo's neural networks.

The code below is not complete – it simply outlines the basic steps involved to build, train and use a neural network with ojAlgo.



Now have a look at that fully functional example...


Sunday 16 September 2018

Introducing Artificial Neural Networks with ojAlgo

With v46 ojAlgo got support for building artificial neural networks. Here's an example of what you can do with it.

The MNIST database is a large image database of handwritten digits that is commonly used for training and testing in the field of machine learning / image categorisation. Information regarding this dataset and various results achieved is widely published.
A correctly modelled/trained neural network should be able to achieve a 5% error rate on this dataset. Most/all published results are better than that. The largest, most advanced, models have managed 0,35%. That's almost unbelievably good. ojAlgo currently doesn't have all the features required to build that kind of model. The model in the program listed below gets about 2.2% error rate. Here are some sample digits/images from the data set.



The program below (with its dependency on ojAlgo) can do the following:

  • Read/parse the files containing the image data and labels.
  • Generate the actual images so that you can inspect them. The example images above are generated with that code.
  • Print images to console (to sanity check results)
  • Model and train feedforward neural networks:
    • Any number of layers
    • Any number of input/output nodes per layer
    • Choose between 5 different activator and 2 different error/loss functions 

The main benefit of using ojAlgo is how easy it is to do this and get good results. Download the example code below (you also need ojAlgo v46.1.1 or later) and run it, and start modifying the network structure, learning rate and other things. (You also need to download the data files, and update the various paths in the programs.)

Friday 14 September 2018

ojAlgo Examples

All ojAlgo example code previously published on the ojAlgo wiki has now been moved to a GitHub Gist. On this page you see the complete contents of that gist. (Never mind the eclipse and git files at the top. Scroll down the page.) When/if anything is added to that gist this page is automatically updated.

Code