{"id":25631051,"url":"https://github.com/anhquoc533/neural-network","last_synced_at":"2025-10-26T01:36:23.980Z","repository":{"id":47461222,"uuid":"516113535","full_name":"AnhQuoc533/neural-network","owner":"AnhQuoc533","description":"A Neural Network framework for building Multi-layer Perceptron model.","archived":false,"fork":false,"pushed_at":"2025-02-18T17:28:59.000Z","size":24814,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T08:04:05.608Z","etag":null,"topics":["artificial-intelligence","artificial-neural-networks","deep-learning","framework","machine-learning","machine-learning-algorithms","neural-network","neural-networks","numpy","python3"],"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/AnhQuoc533.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":"2022-07-20T19:42:23.000Z","updated_at":"2025-02-18T17:29:03.000Z","dependencies_parsed_at":"2025-02-18T18:36:04.260Z","dependency_job_id":null,"html_url":"https://github.com/AnhQuoc533/neural-network","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/AnhQuoc533%2Fneural-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnhQuoc533%2Fneural-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnhQuoc533%2Fneural-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnhQuoc533%2Fneural-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnhQuoc533","download_url":"https://codeload.github.com/AnhQuoc533/neural-network/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248922539,"owners_count":21183942,"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":["artificial-intelligence","artificial-neural-networks","deep-learning","framework","machine-learning","machine-learning-algorithms","neural-network","neural-networks","numpy","python3"],"created_at":"2025-02-22T20:18:26.075Z","updated_at":"2025-10-26T01:36:23.975Z","avatar_url":"https://github.com/AnhQuoc533.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eneural-network\u003c/h1\u003e\n\n---\n**neural-network** is a Python package on TestPyPi that provides a \nMulti-Layer Perceptron (MLP) framework built using only [**NumPy**](https://numpy.org/doc/stable/). \nThe framework supports Gradient Descent, Momentum, RMSProp, and Adam optimizers.\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ch2\u003eTable of Contents\u003c/h2\u003e\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#dependencies\"\u003eDependencies\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#user-installation\"\u003eUser installation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#simple-usage\"\u003eSimple Usage\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#designing-the-model-architecture\"\u003eDesigning the Model Architecture\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#training-the-model\"\u003eTraining the Model\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#making-predictions\"\u003eMaking predictions\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#beyond-the-framework\"\u003eBeyond the Framework\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#activation-functions\"\u003eActivation functions\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#loss-functions\"\u003eLoss functions\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#2d-decision-boundary\"\u003e2D Decision Boundary\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n## Installation\n\n### Dependencies\n```\npython\u003e=3.8\nnumpy\u003e=1.22.1\nmatplotlib\u003e=3.5.1 \n```\n\n### User installation\nYou can install neural-network using `pip`:\n```\npip install neural-network\n```\n\n## Simple Usage\n\n### Designing the Model Architecture\nTo define your MLP model, you need to specify the number of layers and the number of neurons in each one. \\\nUnless you want to manually set up the parameters, the size of the input layer is not needed, as it will be automatically determined in the initial training process.\n```python\nfrom neural_network import NeuralNetwork\nmodel = NeuralNetwork(neurons=[64, 120, 1])\n```\nIn this example, we have a four-layer neural network containing auto-defined input neurons, \nfirst hidden layer with 64 neurons, second hidden layer with 120 neurons, and one output neuron.\n\n### Training the Model\nTo train the model, you need to provide the input data and the corresponding target (or label) data.\n```python\nX = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])\ny = np.array([[0], [1], [1], [0]])\n\nmodel.fit(X, y, epochs=1000, learning_rate=0.1, optimizer='adam')\n```\nWhen training the model without setting the activation functions or/and the loss functions, the framework will automatically do the job for you. It will initialize the parameters and the functions according to the type of model (regression or classification) and its architecture.\n\n### Making predictions\nOnce the model has been trained, you can use it to make predictions by simple call `predict` method.\n```python\npredictions = model.predict(X)\n```\n\n## Beyond the Framework\nApart from the neural network framework, the package also provides:\n### Activation functions\n\u003ctable\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"https://en.wikipedia.org/wiki/Sigmoid_function\"\u003eSigmoid function\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003esigmoid()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"https://www.medcalc.org/manual/tanh-function.php\"\u003eHyperbolic tangent function\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003etanh()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"https://paperswithcode.com/method/relu\"\u003eRectified linear unit\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003erelu()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"https://paperswithcode.com/method/leaky-relu\"\u003eLeaky Rectified linear unit\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003eleaky_relu()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"https://en.wikipedia.org/wiki/Softmax_function\"\u003eSoftmax function\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003esoftmax()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"https://paperswithcode.com/method/gelu\"\u003eGaussian error linear unit\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003egelu()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nAll above functions have 2 parameters:\n* `x`: The input values. Even though some functions can accept numeric primitive data type,\n  it is advised to use NumPy array.\n* `derivative`: A boolean value indicating whether the function computes the derivative on the input `x`. Default is False.\n\n### Loss functions\n\u003ctable\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"\"\u003eLogistic loss function\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003elog_loss()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"\"\u003eCross-entropy loss function\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003ecross_entropy_loss()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"\"\u003eQuadratic loss function\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003ccode\u003equadratic_loss()\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nAll above functions have 3 parameters:\n* `y_pred`: Predicted labels. It must be a 2D NumPy array and have the same size as `y_true`.\n* `y_true`: True labels. It must be a 2D NumPy array and have the same size as `y_pred`.\n* `derivative`: A boolean value indicating whether the function computes the derivative. Default is False.\n\n### 2D Decision Boundary\nThis utility function is used for illustrative purpose. It takes a trained binary classification model, a 2D NumPy input data with 2 attributes, and the corresponding binary label data as input. The function then will plot a 2D decision boundary based on the prediction of the model. \\\nThe input model is not necessarily an instance of **NeuralNetwork**, but it must have `predict`\nmethod that accepts a 2D NumPy array as input.\n```python\nplot_decision_boundary(model, train_x, train_y)\n```\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"img/Figure_1.png\"\u003e\n\u003c/p\u003e\n\n## License\nThis project has MIT License, as found in the [LICENSE](LICENSE) file.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanhquoc533%2Fneural-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanhquoc533%2Fneural-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanhquoc533%2Fneural-network/lists"}