{"id":19176578,"url":"https://github.com/jldbc/numpy_neural_net","last_synced_at":"2025-05-07T19:24:20.952Z","repository":{"id":100931344,"uuid":"76906924","full_name":"jldbc/numpy_neural_net","owner":"jldbc","description":"A simple neural network (multilayer perceptron) with backpropagation implemented in Python with NumPy","archived":false,"fork":false,"pushed_at":"2016-12-20T23:12:52.000Z","size":455,"stargazers_count":29,"open_issues_count":0,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T01:33:12.515Z","etag":null,"topics":["deep-learning","neural-network","numpy","python","scratch"],"latest_commit_sha":null,"homepage":null,"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/jldbc.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":"2016-12-19T23:56:56.000Z","updated_at":"2024-03-13T06:01:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2d0285c-ad35-43ed-950e-e6ee7b09d83c","html_url":"https://github.com/jldbc/numpy_neural_net","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jldbc%2Fnumpy_neural_net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jldbc%2Fnumpy_neural_net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jldbc%2Fnumpy_neural_net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jldbc%2Fnumpy_neural_net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jldbc","download_url":"https://codeload.github.com/jldbc/numpy_neural_net/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252942192,"owners_count":21829026,"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-learning","neural-network","numpy","python","scratch"],"created_at":"2024-11-09T10:29:05.999Z","updated_at":"2025-05-07T19:24:20.927Z","avatar_url":"https://github.com/jldbc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NumPy Neural Network\n#### This is a simple multilayer perceptron implemented from scratch in pure Python and NumPy.\n\nThis repo includes a three and four layer nueral network (with one and two hidden layers respectively), trained via batch gradient descent with backpropogation. The tunable parameters include:\n* Learning rate\n* Regularization lambda\n* Nodes per hidden layer\n* Number of output classes\n* Stopping criterion\n* Activation function\n\nA good starting point for this model is a learning rate of 0.01, regularization of 0.01, 32 nodes per hidden layer, and ReLU activations. These will differ according the context in which the model is used. \n\n\nHere are some results from the three-layer model on some particularly tricky separation boundaries. The model generalizes well to non-linear patterns.\n\n![inline 50%](images/moons.png)![inline 50%](images/circles.png)\n\n\nparameter tuning looked as follows:\n\n\n![inline 50%](images/num_nodes.png)![inline 50%](images/num_observations.png)\n![inline 50%](images/regularization.png)![inline 50%](images/learning_rate.png)\n\nAs you can see, most of the patterns worked as expected. More data led to more stable training, more nodes led to a better model fit, increased regularization led to increased training loss, and a smaller learning rate caused a smoother but slower-moving training curve. Worth noting, however, is how extreme values of some of these values caused the model to become less stable. A high number of observations or learning rate, for example, caused erratic and sub-optimal behaviour during training. This is an indication that there is still a significant that can be done in order to optimize this model. \n\n### lessons learned:\n* Logistic activation functions really do complicate MLP training. Too low of a learning rate, too many observations, and sigmoidal activation functions all made this model unstable, and even broke it in some cases.\n\n* These these models  are incredibly flexible. This simple network was able to approximate every function I threw its way.\n\n* Neural networks are hard. I have a newfound appreciation for the layers of abstraction that tensorflow, keras, etc. provide between programmer and network.\n\n\nThank you to [WildML](http://www.wildml.com/2015/09/implementing-a-neural-network-from-scratch/) for providing a starting point for this project + code, and to Ian Goodfellow's book *Deep Learning* for background on the algorithms and parameter tuning.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjldbc%2Fnumpy_neural_net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjldbc%2Fnumpy_neural_net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjldbc%2Fnumpy_neural_net/lists"}