{"id":16048937,"url":"https://github.com/devongovett/snneuralnet","last_synced_at":"2025-08-21T02:06:54.893Z","repository":{"id":62454133,"uuid":"14851963","full_name":"devongovett/SNNeuralNet","owner":"devongovett","description":"A neural network library for Objective-C","archived":false,"fork":false,"pushed_at":"2013-12-05T21:43:55.000Z","size":196,"stargazers_count":42,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-29T15:43:10.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/devongovett.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}},"created_at":"2013-12-02T03:34:33.000Z","updated_at":"2024-02-16T13:09:17.000Z","dependencies_parsed_at":"2022-11-02T00:00:51.495Z","dependency_job_id":null,"html_url":"https://github.com/devongovett/SNNeuralNet","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/devongovett/SNNeuralNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2FSNNeuralNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2FSNNeuralNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2FSNNeuralNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2FSNNeuralNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devongovett","download_url":"https://codeload.github.com/devongovett/SNNeuralNet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2FSNNeuralNet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271415496,"owners_count":24755639,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-09T00:11:29.108Z","updated_at":"2025-08-21T02:06:54.865Z","avatar_url":"https://github.com/devongovett.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"SNNeuralNet\n===============\n\nA neural network library for Objective-C based on [brain.js](https://github.com/harthur/brain), for iOS and Mac OS X.\n\n## Example\n\nThis example approximates the XOR function using a neural network:\n\n```objective-c\n#import \"SNNeuralNet.h\"\n\nSNTrainingRecord records[] = {\n    {SNInput(0,0), SNOutput(0)},\n    {SNInput(0,1), SNOutput(1)},\n    {SNInput(1,0), SNOutput(1)},\n    {SNInput(1,1), SNOutput(0)}\n};\n\nSNNeuralNet *net = [[SNNeuralNet alloc] initWithTrainingData:records \n                                                  numRecords:4\n                                                   numInputs:2\n                                                  numOutputs:1];\n\ndouble *output = [net runInput:SNInput(1, 0)];\nprintf(\"%f\\n\", output[0]); // 0.987\n```\n\n## Documentation\n\nYou can find class documentation generated by appledoc [here](http://devongovett.github.io/SNNeuralNet/docs/Classes/SNNeuralNet.html).\n\n## Creating an SNNeuralNet\n\nThere are several ways of creating an `SNNeuralNet` instance. The base init method is:\n\n```objective-c\nSNNeuralNet *net = [[SNNeuralNet alloc] initWithInputs:2 outputs:1];\n```\n\nThis will create a default neural network with one hidden layer, which is good enough for many\nusecases. However, you may also create a neural network with more hidden layers with sizes of your\nchoosing.\n\n```objective-c\nSNNeuralNet *net = [[SNNeuralNet alloc] initWithInputs:2 hiddenLayers:@[@3, @4] outputs:1];\n```\n\nAdditionally, you can create and train a network in one step, though this makes it impossible to \nconfigure some aspects of the network and create custom hidden layers.\n\n```objective-c\n// see the section on training below\nSNTrainingRecord records[] = {\n    {SNInput(0,0), SNOutput(0)},\n    {SNInput(0,1), SNOutput(1)},\n    {SNInput(1,0), SNOutput(1)},\n    {SNInput(1,1), SNOutput(0)}\n};\n\nSNNeuralNet *net = [[SNNeuralNet alloc] initWithTrainingData:records \n                                                  numRecords:4\n                                                   numInputs:2\n                                                  numOutputs:1];\n```\n\n## Configuration\n\nThere are several configurable properties of an SNNeuralNet. Once you have an instance,\nyou can set these properties. These properties will have no effect after training, so make\nsure to use one of the constructors that does not also do training. Their defaults are included\nbelow.\n\n```objective-c\nnet.maxIterations = 20000;  // maximum training iterations\nnet.minError = 0.005;       // error threshold to reach\nnet.learningRate = 0.3;     // influences how quickly the network trains\nnet.momentum = 0.1;         // influences learning rate\n```\n\n## Training\n\nOnce you've created and configured your network, you should train it with some known data. The \nnetwork can only be trained once, so include all training data at once. If you attempt to call\nthe `train` method more than once, `-1` will be returned. You can check `net.isTrained` to see \nif a network has already been trained.\n\nBefore you can train, you need to make an array of `SNTrainingRecord`s.  These are C structures\nthat hold input and output arrays of doubles. You can have as many inputs or outputs as you like,\nbut all data must have the same number of inputs and outputs. There are convienience macros called\n`SNInput` and `SNOutput` that wrap data in an array.\n\nWhen you're ready to train the network, use the train method, and pass the record array and number of records.\n\n```objective-c\nSNTrainingRecord records[] = {\n    {SNInput(0,0), SNOutput(0)},\n    {SNInput(0,1), SNOutput(1)},\n    {SNInput(1,0), SNOutput(1)},\n    {SNInput(1,1), SNOutput(0)}\n};\n\ndouble error = [net train:records numRecords:4];\n```\n\nThe `train` method returns the amount of error that occurred in training, which should be lower than \n`net.minError` unless `net.maxIterations` was reached.\n\n## Running unknown inputs\n\nThe real usefulness of a neural network is its ability to predict outputs for unknown inputs. Once your\n`SNNeuralNet` has been trained, you can use the `runInput` method to get predicted outputs.\n\n```objective-c\ndouble *output = [net runInput:SNInput(1, 0.4, 0)];\n```\n\n`runInput` returns an array of doubles, including `net.numOutputs` entries.\n\n# License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fsnneuralnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevongovett%2Fsnneuralnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fsnneuralnet/lists"}