Home

Awesome

SwiftSimpleNeuralNetwork

A simple multi-layer feed-forward neural network with backpropagation built in Swift.

Philosophy

This teaching project is proclaimed simple for two reasons:

Contributions to the project will be measured not only by their functional aspects (improved performance, more features) but also by how much they stick to the philosophy.

Installation

The project requires Xcode 10.2 and Swift 5.

Manual

For the present, the best way to try the project out is through the wine and iris Xcode unit tests. Just download or clone the repository and run them from within Xcode.

SPM

You can also install the project's main files (but not the unit tests) through SPM via this repository.

Mac Example App

The example app for macOS that comes with SwiftSimpleNeuralNetwork trains on 60,000 MNIST sample images and then predicts another 10,000 testing images. In my testing it reaches as high as 94% accuracy without much tuning (just many batches of training on the full dataset). This is definitely not state of the art, but for a simple neural network, it's a decent demonstration.

MNIST Example App Screenshot

Unit Tests

A check indicates a test is passing/working.

Book Chapter

Chapter 7 of Classic Computer Science Problems in Swift is based on this project. It contains it a step-by-step tutorial, explaining how a slightly more primitive version of the project works.

License, Contributions, and Attributions

SwiftSimpleNeuralNetwork is Copyright 2016-2019 David Kopec and licensed under the Apache License 2.0 (see LICENSE). As per the Apache license, contributions are also Apache licensed by default. And contributions are welcome!

The wine and iris datasets in the unit tests are provided curtosy of the UCI Machine Learning Repository which should be cited as:

Lichman, M. (2013). UCI Machine Learning Repository [http://archive.ics.uci.edu/ml]. Irvine, CA: University of California, School of Information and Computer Science.

The MNIST dataset is from LeCun, Cortes, and Burges.

The overall neural network algorithm implemented throughout the project was derived primarily from Chapter 18 of Artificial Intelligence: A Modern Approach (Third Edition) by Stuart Russell and Peter Norvig.

A few small individual utility functions in Functions.swift are from third party sources and cited appropriately in-source.

Future Directions