Implementation of a simple MLP in Python. Features a full forward pass, backpropagation and gradient descent. Dependencies include numpy for matrix operations, sklearn for the dataset and confusion matrices, and matplotlib for visualization.
-
Open the directory in a unix-terminal with bash and create a virtual environment. For fish users, add
activate.fishwhen sourcing.python3 -m venv venv source venv/bin/activate # On macOS/Linux .\venv\Scripts\activate # On Windows
-
Check for dependencies by running
pip install -r requirements.txt
-
Execute the script
python3 main.py
Keep in mind that you have to close every plot manually if you run from the command line.
We support flexible tweaking of our models hyperparameters with argparse. Just invoke the parameter(s) you want to adjust when running our script via the command line. Some flags that you might want to try are
--epochsexpects an integer value that sets the training duration.--lrexpects a floating-point value to set the learning rate of the model.--hiddenexpects two integers that set the dimensions of the hidden layers.--losslets you pick mean-squared error withmseand CrossEntropyLoss withentropy.--activationlets you pick betweenrelu,softplusandsigmoidactivation in the hidden layers.
Remember that you can see a list of all possible arguments with python3 main.py -h.