Skip to content

Implementing a neural network from scratch in NumPy

Notifications You must be signed in to change notification settings

joeldudley/neural-net

Repository files navigation

Neural Net

A from-scratch implementation of a feedforward neural network. Written in Python with NumPy.

Usage

Try it out!

Run this test to train a neural net on the MNIST database.

Training

Create and train a network using:

net = neural_net.Network([input_layer_size, hidden_layer_one_size, ..., output_layer_size])
net.train(training_inputs, training_outputs, epochs, batch_size, learning_rate, test_inputs, test_outputs)

Where training_inputs is a numpy ndarray of dimensions [training set size, input layer size, 1], and training_outputs is a list of numpy ndarrays of dimensions [output layer size, 1].

test_inputs and test_outputs are optional. If specified, they are used to evaluate and print the performance of the network after each epoch.

Evaluation

Evaluate the network against a test set:

net.percentage_correct(test_inputs, test_outputs)

Classification

Classify new samples using the trained network with:

net.classify(sample)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

Implementing a neural network from scratch in NumPy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages