{"id":27650809,"url":"https://github.com/grgomariani/mmnn","last_synced_at":"2025-04-24T03:48:05.765Z","repository":{"id":287229603,"uuid":"116031125","full_name":"GrgoMariani/mmNN","owner":"GrgoMariani","description":"micro managed NEURAL NETWORK (c++11 / Python)","archived":false,"fork":false,"pushed_at":"2019-06-22T12:16:57.000Z","size":217,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-24T03:48:02.117Z","etag":null,"topics":["ai","ann","cpp","dnn","mnist","neural-nets","neural-network","neurons","python-module"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GrgoMariani.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,"zenodo":null}},"created_at":"2018-01-02T15:48:21.000Z","updated_at":"2022-06-20T22:08:06.000Z","dependencies_parsed_at":"2025-04-10T17:09:39.340Z","dependency_job_id":"2fb38be4-2b94-47b6-8bd9-4f1f3a957034","html_url":"https://github.com/GrgoMariani/mmNN","commit_stats":null,"previous_names":["grgomariani/mmnn"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrgoMariani%2FmmNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrgoMariani%2FmmNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrgoMariani%2FmmNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrgoMariani%2FmmNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrgoMariani","download_url":"https://codeload.github.com/GrgoMariani/mmNN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250560007,"owners_count":21450168,"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":["ai","ann","cpp","dnn","mnist","neural-nets","neural-network","neurons","python-module"],"created_at":"2025-04-24T03:48:05.116Z","updated_at":"2025-04-24T03:48:05.750Z","avatar_url":"https://github.com/GrgoMariani.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mmNN\n##\n### micro managed NEURAL NETWORK\n\n![mmNN](Documentation/images/mmNN.png?raw=true \"micro managed NEURAL NETWORK\")\n\n####  Brief\n\nA simple to use, ___lightweight___ neural network _C++ library/Python module_.\n\nWatch out as this is still in development and written only for ___C++11___ and ___Python___, so I would advise you away from using it in something \"big\". Not to mention that this also served as a pet project to confirm some of my intuitions about NNs.\n\nThe main motivation behind this project was a deeper evaluation of abstractions in neural nets. While other frameworks might use whole layers as their 'atoms' for building the neural net, mmNN's is the neuron and the synapse.\n\nConsider this :\n![A different example](Documentation/images/picture1.png?raw=true \"A different example\")\n\nThis neural net has 3 inputs and 3 outputs but how many layers??? One might say 5 as the furthest road from INPUT 1 to OUT 2 is 4, but INPUT 3 directly 'touches' OUT 3 so is it 2 layers??? Or is it something in between.\n\nConsider a problem where you need to find out if a given image is that of a circle? Next consider if it is an image of a car? First one might be easily solved in a couple of layers, but the other one needs a lot more abstractions to work properly, so a lot more layers.\nNow consider a problem where you need to find out if there is a car and a circle in an image??? Why would our circle abstraction need to be represented in all the layers after it has been identified???\n\n![Circle Car](Documentation/images/CircleAndCar.png?raw=true \"Circle and Car\")\n\n(A slightly better analogy could have been a red hat.)\n\n#### Neuron and Synapse\n\nOne thing that was quite difficult to do was simulating the pooling layer. However after some thought I've decided something new called the accumulation function.\n![Neuron](Documentation/images/NeuronArchitecture.png?raw=true \"Neuron Architecture\")\nShould the concept of activation be clear to you (ReLU, Sigmoid, Sign, ... ) the accumulation should also be.\n![Accumulation](Documentation/images/Accumulation.png?raw=true \"Accumulation\")\n\nIt should be clear how pooling could be simulated now.\n\n#### Install\nI've made a ___Makefile___ which should take care of most of the Python installation. Be sure to change the Python version to the one you use. Currently it's set to Python2.7 .\n```\n$ sudo apt-get install libboost-all-dev python-dev python3-dev\n$ git clone http://www.github.com/GrgoMariani/mmNN.git\n$ cd mmNN\n$ make\n$ sudo make install\n```\nYou can check out the example with:\n```\n$ python2.7 example.py\n```\n![Example 1](Documentation/images/Example1.png?raw=true \"Example 1\")\n\nThe example produces the net with 4 inputs and 1 output, as well as two hidden layers. The network teaches to convert the binary number representation to decimal of 4 inputs.\n\nCheck the example2.py also. It does the same thing in a loop, and the outputs are squares now.\nBe sure to start the example a couple of times and see how it sometimes learns quickly, sometimes slow, and sometimes not at all.\n\n#### Usage\nMost you need to know should be covered in the examples. mmNN is quite new so ... , keep it simple.\n\nAfter importing the module you should create your net and define number of inputs and outputs.\n```\nfrom pymmNN import NeuralNetwork, ActivationType, AccumulationType, ErrorType\n\nnet = NeuralNetwork( NUMBER_OF_INPUTS, NUMBER_OF_OUTPUTS, ActivationType.LINEAR)\nnet.setLearningRate(0.005)\n```\n\nTo get the first and the last layer of neurons:\n```\ninput_layer =   net.getInputLayer()\noutput_layer =  net.getOutputLayer()\n```\nWhat we have so far is this:\n![Usage 1](Documentation/images/Usage1.png?raw=true \"Usage 1\")\n\n3 Inputs, 2 Outputs and 1 hidden bias neuron. No neurons are connected to each other.\nWe can add one neuron and connect it to each input and each output so that we have INPUT-\u003eNeuron-\u003eOUTPUT direction.\n```\nnewNeuron = net.createNeuron(ACTIVATION_FUNCTION_TYPE, ACCUMULATION_FUNCTION_TYPE) # Define the activations and accumulation\nnet.linkTwoNeurons(input_layer[0], newNeuron, -1.4 )\nnet.linkTwoNeurons(input_layer[1], newNeuron, 2.0 )\nnet.linkTwoNeurons(input_layer[2], newNeuron, 1.2 )\nnet.linkToBias(newNeuron, 0.6 )\n```\nWe have connected the input layers to new neuron, as well as the bias. Like this:\n![Usage 2](Documentation/images/Usage2.png?raw=true \"Usage 2\")\n\nWe only need to connect the output neurons to it and the bias to output neurons.\n```\nnet.linkTwoNeurons(newNeuron, output_layer[0], 4. )\nnet.linkTwoNeurons(newNeuron, output_layer[1], -2.34 )\nnet.linkToBias(output_layer[0], 0.05 )\nnet.linkToBias(output_layer[1], 12.0 )\n```\n![Usage 3](Documentation/images/Usage3.png?raw=true \"Usage 3\")\n\nAll the weights have been set.\n\nOnce all the connections are set feel free to use your network and \"teach it\" new tricks.\n\nInput _list_ of NOI size and expect _list_ of NOO size as output.\n```\n# Create some input data\nINPUT_DATA = [1. , 2. , 3.]\n# Forward the data and get OUTPUT_DATA\nOUTPUT_DATA = net.forward(data)\n# You can check the outputs you got from the network in OUTPUT_DATA\nDESIRED_DATA = [6., 1.]\n# You will need to define ERROR_FUNCTION for backpropagation while setting up the net, as well as the learning rate\nnet.backprop( DESIRED_DATA)\n# The network has learned something now\n```\n\n#### Other\nThis short intro explains most of the Python module. The default error function is _loss squared_.\n\n[Check the Python example]( example.py )\n\n[Check the Python example2]( example2.py )\n\n[For C++ code check this link]( Documentation/README.md )\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrgomariani%2Fmmnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrgomariani%2Fmmnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrgomariani%2Fmmnn/lists"}