{"id":26235937,"url":"https://github.com/clement-w/nnjulia.jl","last_synced_at":"2025-07-19T23:36:36.911Z","repository":{"id":67395602,"uuid":"459656752","full_name":"Clement-W/NNJulia.jl","owner":"Clement-W","description":"Minimalist neural network library written in Julia for educational purposes","archived":false,"fork":false,"pushed_at":"2023-05-22T21:13:03.000Z","size":5330,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-13T03:19:08.638Z","etag":null,"topics":["automatic-differentiation","deep-learning","julia"],"latest_commit_sha":null,"homepage":"https://clement-w.github.io/NNJulia.jl/dev/","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Clement-W.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-02-15T16:21:19.000Z","updated_at":"2023-08-23T13:42:10.000Z","dependencies_parsed_at":"2025-03-13T03:19:12.106Z","dependency_job_id":"41fc5cbb-2d61-49c9-8b47-2eac204145b4","html_url":"https://github.com/Clement-W/NNJulia.jl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Clement-W/NNJulia.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FNNJulia.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FNNJulia.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FNNJulia.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FNNJulia.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clement-W","download_url":"https://codeload.github.com/Clement-W/NNJulia.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FNNJulia.jl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266042021,"owners_count":23867960,"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":["automatic-differentiation","deep-learning","julia"],"created_at":"2025-03-13T03:18:49.863Z","updated_at":"2025-07-19T23:36:36.900Z","avatar_url":"https://github.com/Clement-W.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr /\u003e\n\u003ch1 align=\"left\"\u003eNNJulia\u003c/h1\u003e\n\n\n[![Build status (Github Actions)](https://github.com/Clement-W/NNJulia.jl/workflows/CI/badge.svg)](https://github.com/Clement-W/NNJulia.jl/actions)\n[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://clement-w.github.io/NNJulia.jl/dev/)\n[![codecov](https://codecov.io/gh/Clement-W/NNJulia.jl/branch/main/graph/badge.svg?token=J0K5VA4UXG)](https://codecov.io/gh/Clement-W/NNJulia.jl)\n\n## About The Project\n\nThis project aims to develop a complete deep learning library from scratch. Conducted for educational purposes, this project helps me to better understand how famous libraries such as PyTorch are working, and how the learning algorithms are implemented at lower levels.\n\nThe programming language used for this project is Julia. Julia is a recent programming language with a fast-growing community. It is made for scientific computation, and is famous for being faster than Python or Matlab. This open source programming language is dynamically typed and uses multiple dispatch as a paradigm. As Julia is designed for high performance, it makes it perfect for data science, machine learning and deep learning. When I started the project, I did not know anything about Julia, so it was also a good way to learn this language.\n\nNNJulia is based on the principle of automatic differentiation (AD). AD is a general way of evaluating the derivative of a function defined by a computer program. It relies on a calculus formula named the chain rule. By applying the chain rule on every elementary mathematical operation and functions involved in a complicated mathematical function, derivatives of arbitrary order can be computed automatically. A fast reverse-mode automatic differentiation is mandatory during the backpropagation phase. It allows to compute efficiently the gradients required to update the parameters of a neural network. \n\nTo implement AD, a structure Tensor is used. A tensor is a N-dimensional array that can be differentiated. By using mathematical operations and functions between tensors, a computational graph is implicitly created. This allows to store the dependencies between tensors, with respect to the operations that link them.\n\nIn the end the library NNJulia offers a simple programming interface to create and train sequential neural networks composed of dense layers (convolutional layers are not implemented yet). [The documentation is also available online.](https://clement-w.github.io/NNJulia.jl/dev/)\n\nAs you can see in examples/ it is possible to classify handwritten digits from the MNIST dataset with a decent accuracy. An example of spiral data points classification is also available.\n\n\n## Getting Started\n\nTo get a local copy up and running follow these simple example steps.\n\n### Prerequisites\n\n* [Julia 1.7](https://julialang.org/)\n\n### Installation\n\n\n1. Clone the repo and launch Julia\n```sh\ngit clone https://github.com/Clement-W/NNJulia.jl\ncd NNJulia.jl\njulia\n```\n   \n2. Instantiate the package\n```julia\njulia\u003e using Pkg\njulia\u003e Pkg.activate(\".\")\njulia\u003e Pkg.instantiate()\njulia\u003e using NNJulia\n```\n   \n3. Now you're ready to use NNJulia !\n\n\n## Usage\n\n### Create a model \n\n```julia\nmodel = Sequential(\n        Flatten(),\n        Dense(784, 16, relu),\n        Dense(16, 16, relu),\n        Dense(16, 10, softmax),\n    )\n  ```\n \n ### Prepare for training\n \n ```julia\n# Initialise the optimiser, the loss function and the metrics used to compute accuracy\nopt = GradientDescent(0.05)\nloss = BinaryCrossentropy()\nmetrics = BinaryAccuracy()\n\n# Pass it to the TrainParameters struct that will be used during training\ntrainParams = TrainParameters(opt, loss, metrics)\n\n# Training specifications\nbatchsize = 64\nnbEpochs = 25;\n ```\n \n ### Load the data into a DataLoader\n \n ```julia\ntrainData = DataLoader(train_x, train_y_hot, batchsize,shuffle=true);\n ```\n \n ### Train the model\n \n ```julia\n history = train!(model, trainParams, trainData, nbEpochs)\n ```\n \nPlot the evolution of accuracy and loss during training:\n```julia\np1 = plot(history[\"accuracy\"],label=\"Accuracy\",legend=:topleft)\np2 = plot(history[\"loss\"],label=\"Loss\")\nplot(p1,p2,layout=2)\n```\n \n ###  Evaluate the model\n \n \n ```julia\nacc = evaluate(model,metrics,test_x,test_y_hot)\nprintln(\"accuracy on test data = \" * string(acc*100) * \"%\")\n```\n \n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclement-w%2Fnnjulia.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclement-w%2Fnnjulia.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclement-w%2Fnnjulia.jl/lists"}