{"id":19608962,"url":"https://github.com/davecom/swiftsimpleneuralnetwork","last_synced_at":"2025-04-27T20:33:16.866Z","repository":{"id":66360403,"uuid":"62373086","full_name":"davecom/SwiftSimpleNeuralNetwork","owner":"davecom","description":"A simple multi-layer feed-forward neural network with backpropagation built in Swift.","archived":false,"fork":false,"pushed_at":"2024-09-17T09:45:55.000Z","size":11638,"stargazers_count":30,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-05T03:23:01.521Z","etag":null,"topics":["backpropagation","neural-network"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davecom.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-07-01T07:19:52.000Z","updated_at":"2025-02-14T16:33:51.000Z","dependencies_parsed_at":"2023-02-22T12:46:35.210Z","dependency_job_id":null,"html_url":"https://github.com/davecom/SwiftSimpleNeuralNetwork","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/davecom%2FSwiftSimpleNeuralNetwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davecom%2FSwiftSimpleNeuralNetwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davecom%2FSwiftSimpleNeuralNetwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davecom%2FSwiftSimpleNeuralNetwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davecom","download_url":"https://codeload.github.com/davecom/SwiftSimpleNeuralNetwork/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251204795,"owners_count":21552294,"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":["backpropagation","neural-network"],"created_at":"2024-11-11T10:18:44.775Z","updated_at":"2025-04-27T20:33:11.854Z","avatar_url":"https://github.com/davecom.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftSimpleNeuralNetwork\nA simple multi-layer feed-forward neural network with backpropagation built in Swift.\n\n## Philosophy\nThis *teaching* project is proclaimed *simple* for two reasons:\n- The code aims to be simple to understand (even at the expense of performance). I built this project to learn more about implementing neural networks. It does not aim to be state of the art or feature complete, but instead approachable.\n- The type of neural network targetted is very specific - only multi-layer feed-forward backpropagation networks. Why? Because we're keeping it simple,\n\nContributions to the project will be measured not only by their functional aspects (improved performance, more features) but also by how much they stick to the philosophy.\n\n## Installation\n\n**The project requires Xcode 10.2 and Swift 5.**\n\n### Manual\n\nFor the present, the best way to try the project out is through the wine and iris Xcode unit tests. Just download or clone the repository and run them from within Xcode.\n\n### SPM\n\nYou can also install the project's main files (but not the unit tests) through SPM via this repository.\n\n## Mac Example App\n\nThe example app for macOS that comes with SwiftSimpleNeuralNetwork trains on 60,000 MNIST sample images and then predicts another 10,000 testing images. In my testing it reaches as high as 94% accuracy without much tuning (just many batches of training on the full dataset). This is definitely not state of the art, but for a *simple* neural network, it's a decent demonstration.\n\n![MNIST Example App Screenshot](screenshot.png)\n\n## Unit Tests\n\nA check indicates a test is passing/working.\n- [x] `IrisTest.swift` uses the classic data set (contained in `iris.csv`) to classify 150 irises by four attributes.\n- [x] `WineTest.swift` uses a data set of 178 wines across thirteen attributes (contained in `wine.csv`) to classify wines by cultivar (three cultivars total). The test trains on the first 150 and then validates itself by classifying the remaining 28.\n- [ ] `SinTest.swift` tries to learn to approximate the sin() function. ~80% of predictions come close to correct values.\n\n## Book Chapter\n\nChapter 7 of [Classic Computer Science Problems in Swift](https://github.com/davecom/ClassicComputerScienceProblemsInSwift) is based on this project. It contains it a step-by-step tutorial, explaining how a slightly more primitive version of the project works.\n\n## License, Contributions, and Attributions\n\nSwiftSimpleNeuralNetwork is Copyright 2016-2019 David Kopec and licensed under the Apache License 2.0 (see LICENSE). As per the Apache license, contributions are also Apache licensed by default. And contributions are welcome!\n\nThe wine and iris datasets in the unit tests are provided curtosy of the UCI Machine Learning Repository which should be cited as:\n\u003e Lichman, M. (2013). UCI Machine Learning Repository [http://archive.ics.uci.edu/ml]. Irvine, CA: University of California, School of Information and Computer Science.\n\nThe MNIST dataset is from [LeCun, Cortes, and Burges](http://yann.lecun.com/exdb/mnist/).\n\nThe overall neural network algorithm implemented throughout the project was derived primarily from Chapter 18 of Artificial Intelligence: A Modern Approach (Third Edition) by Stuart Russell and Peter Norvig.\n\nA few small individual utility functions in `Functions.swift` are from third party sources and cited appropriately in-source.\n\n## Future Directions\n\n- Improved in-source documentation\n- Improved documentation in this README\n- More unit tests\n- More activation functions\n- Utility function to archive (serialize) and recreate (deserialize) trained neural networks\n- Better testing of networks with more than one hidden layer\n- Improved performance\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavecom%2Fswiftsimpleneuralnetwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavecom%2Fswiftsimpleneuralnetwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavecom%2Fswiftsimpleneuralnetwork/lists"}