An example implementation of a Multilayer Perceptron in PHP 8.3, created for educational purposes.
To run the scripts, you need to install the php-gd library. It is used to parse PNG files.
sudo apt-get install php-gdTo train the model from scratch, delete the saved weights from the model folder and run the following script:
php train.phpThe repository includes a pre-trained model. To verify its performance, run the command:
php test.phpThe model is trained using the MNIST dataset. All external resources can be found in the References section.
- Mastering the Multi-Layer Perceptron (MLP) for Image Classification
- Michael A. Nielsen, "Neural Networks and Deep Learning", Determination Press, 2015
- Neural Network Course in JavaScript
- The MNIST database of handwritten digits
- Simple script to convert MNIST to PNG format
- He/Xavier initialization & activation functions: choose wisely