Neural Networks from scratch in Go (standard library only)
Limitations:
- No external libraries or modules
- For simplicity, I limit the input shape to (1,x)
Goal:
- Multilayer Perceptron (done)
- Binary classification (done)
- Support for multiple outputs (Multiple classification) (halted)
- Visualization (in progress)
Current status:
- Define basic data types (Input, Neuron, Layer)
- Calculate neuron outputs [type: (1,x) array of weight*input+bias]
- Define gradient methods and neural structure (heavily inspired by Karpathy's video)
- Backpropagate and train for k steps
- Produce and validate output
- More activation functions (Sigmoid and ReLU)
- Binary crossentropy
Goml Visualizer (in progress):
The Goml Visualizer was written using Wails with React in Typescript for the frontend. The gif above shows the test mode, which allows you to browse your test set and see which values were correctly predicted by the model.
References and inspiration:
- Sebastian Lauge's Neural Networks Video
- Andrej Karpathy's Micrograd Breakdown
- Aurelien Geron: Hands-On Machine Learning with Scikit-Learn and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems (March 13, 2017, O'Reilly)
How to run
- Make sure you have a valid Go installation by running
go version - Clone the repo
- Run with
go run . - The network parameters can be tweaked inside the
lib/network/run.gofile. Neuron activation functions can be found underlib/network/neuron.goand the engine blocks can be found underlib/network/value.go.