{"id":19783873,"url":"https://github.com/luluw8071/neural-network-from-scratch-using-numpy","last_synced_at":"2026-05-15T02:05:38.230Z","repository":{"id":230609190,"uuid":"779332603","full_name":"LuluW8071/Neural-Network-From-Scratch-Using-Numpy","owner":"LuluW8071","description":"A linear neural network from scratch using Numpy for training MNIST Dataset","archived":false,"fork":false,"pushed_at":"2024-03-31T06:44:35.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-11T02:47:47.145Z","etag":null,"topics":["deep-neural-networks","digit-recognition-mnist","mnist-classification","neural-network-from-scratch","numpy","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LuluW8071.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-29T15:34:08.000Z","updated_at":"2024-04-01T06:23:09.000Z","dependencies_parsed_at":"2024-11-12T06:09:31.752Z","dependency_job_id":"179e2846-d878-4c04-93bc-a58b6d190182","html_url":"https://github.com/LuluW8071/Neural-Network-From-Scratch-Using-Numpy","commit_stats":null,"previous_names":["luluw8071/neural-network-from-scratch-using-numpy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuluW8071%2FNeural-Network-From-Scratch-Using-Numpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuluW8071%2FNeural-Network-From-Scratch-Using-Numpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuluW8071%2FNeural-Network-From-Scratch-Using-Numpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuluW8071%2FNeural-Network-From-Scratch-Using-Numpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LuluW8071","download_url":"https://codeload.github.com/LuluW8071/Neural-Network-From-Scratch-Using-Numpy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241116732,"owners_count":19912429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-neural-networks","digit-recognition-mnist","mnist-classification","neural-network-from-scratch","numpy","python"],"created_at":"2024-11-12T06:09:29.727Z","updated_at":"2026-05-15T02:05:38.148Z","avatar_url":"https://github.com/LuluW8071.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Neural-Network-From-Scratch-Using-Numpy\n\nThis repository contains code for building and training a neural network from scratch using Numpy, a Python library for numerical computing. The neural network is trained on the **MNIST dataset** for digit recognition.\n\n![Linear Neural Network](https://miro.medium.com/v2/resize:fit:679/1*0WUg6f46UmDYij6nAqh-7w.gif)\n\n## Overview\n\nIn this project, we implement a simple neural network architecture with one hidden layer using the following steps:\n\n| Step               | Description                                                                                       |\n|--------------------|---------------------------------------------------------------------------------------------------|\n| **Data Loading**   | Load the **MNIST dataset** containing images of handwritten digits which can be downloaded form [here](https://www.kaggle.com/competitions/digit-recognizer)          |\n| **Data Preprocessing** | Normalize the images to have pixel values between 0 and 1. **One-hot encode** labels for classification. |\n| **Model Architecture** | Construct a neural network with an **input layer**, a **hidden layer** with **ReLU** activation, and an **output layer** with **softmax** activation. |\n| **Training**       | Train the neural network using **batch gradient descent** with **backpropagation**. Monitor training for loss and accuracy. |\n| **Evaluation**     | Evaluate the trained model on a separate test set to measure its performance.                     |\n| **Prediction**     | Use the trained model to make predictions on new unseen data.                                      |\n\n## Usage\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/LuluW8071/Neural-Network-From-Scratch-Using-Numpy.git\n```\n\n2. Install the required dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n3. Run the training script:\n\n```bash\npython main.py --train_path \"/path/to/train.csv\" --test_path \"/path/to/test.csv\" --plot 1\n```\n\nYou can also adjust other parameters for train configs as needed. Here's a table summarizing the command-line arguments accepted by the script:\n\n| Argument          | Description                                                                                   |\n|-------------------|-----------------------------------------------------------------------------------------------|\n| `--train_path`    | Path to the CSV file containing the training data.                                            |\n| `--test_path`     | Path to the CSV file containing the test data.                                                |\n| `--learning_rate` | Learning rate to be used for training the model. Default is `0.001`.                            |\n| `--epochs`        | Number of epochs for training the model. Default is `150`.                                       |\n| `--batch_size`    | Batch size to be used during training. Default is `64`.                                          |\n| `--plot`          | Whether to plot the loss and accuracy curves after training. Set to `1` to plot, `0` otherwise.    |\n| `--save_path`     | Directory to save the submission file. Default is `current_directory`.                           |\n\n#### Sample Demo Run Output\n```bash\n(env) PS D:\\Neural-Network-From-Scratch-Using-Numpy\u003e py .\\main.py --epochs 150 --plot 1 --train_path \".\\train.csv\" --test_path \".\\test.csv\"\nLoaded train.csv and test.csv\n100%|███████████████████████████████████████████████████████| 150/150 [07:27\u003c00:00,  2.99s/it, accuracy=1, loss=1.3e-5]\nSaved inference.csv\n```\n\n4. After training, the model will make predictions on the `test.csv` set and save the results in a `inference.csv` file.\n\n### Accuracy and Loss Curves\n![Figure_1](https://github.com/LuluW8071/Neural-Network-From-Scratch-Using-Numpy/assets/107304848/62af617d-901b-42d7-b1c9-2354dbe8bc34)\n\nAlso if you want the **CNN(Convolutional Neural Network)** implementation, you can find the notebook [here](https://www.kaggle.com/code/luluw8071/mnist-trained-on-tinyvgg-model-with-pytorch?scriptVersionId=168950513). \n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n--- \n\nFeel free to report any issues you encounter.\u003c/br\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/74038190/213844263-a8897a51-32f4-4b3b-b5c2-e1528b89f6f3.png\" width=\"25px\" /\u003e Don't forget to star the repo :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluluw8071%2Fneural-network-from-scratch-using-numpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluluw8071%2Fneural-network-from-scratch-using-numpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluluw8071%2Fneural-network-from-scratch-using-numpy/lists"}