{"id":25830753,"url":"https://github.com/atharvaaalok/deepfusion","last_synced_at":"2025-07-18T15:37:39.755Z","repository":{"id":241265850,"uuid":"793316363","full_name":"atharvaaalok/deepfusion","owner":"atharvaaalok","description":"A highly modular and customizable Deep Learning framework.","archived":false,"fork":false,"pushed_at":"2024-05-23T16:16:21.000Z","size":258,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-09T06:08:59.593Z","etag":null,"topics":["deep-learning","machine-learning","neural-network","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/deepfusion/","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/atharvaaalok.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":"2024-04-29T01:37:06.000Z","updated_at":"2025-06-03T07:55:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"3b93f5ec-6f33-486d-a96e-af1ff97cd494","html_url":"https://github.com/atharvaaalok/deepfusion","commit_stats":null,"previous_names":["atharvaaalok/deepfusion"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/atharvaaalok/deepfusion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atharvaaalok%2Fdeepfusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atharvaaalok%2Fdeepfusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atharvaaalok%2Fdeepfusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atharvaaalok%2Fdeepfusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atharvaaalok","download_url":"https://codeload.github.com/atharvaaalok/deepfusion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atharvaaalok%2Fdeepfusion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264608262,"owners_count":23636695,"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":["deep-learning","machine-learning","neural-network","python"],"created_at":"2025-02-28T19:30:59.589Z","updated_at":"2025-07-18T15:37:39.733Z","avatar_url":"https://github.com/atharvaaalok.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cpicture\u003e\n        \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/atharvaaalok/deepfusion/main/assets/logos/Light_TextRight.svg\"\u003e\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/atharvaaalok/deepfusion/main/assets/logos/Dark_TextRight.svg\"\u003e\n        \u003cimg alt=\"DeepFusion Logo with text below it. Displays the light version in light mode and\n        the dark version logo in dark mode.\" src=\"https://raw.githubusercontent.com/atharvaaalok/deepfusion/main/assets/logos/Light_TextRight.svg\" width=\"100%\"\u003e\n    \u003c/picture\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\nDeepFusion is a highly modular and customizable deep learning framework.\n\nIt is designed to provide strong and explicit control over all data, operations and parameters while\nmaintaining a simple and intuitive code base.\n\n\n## Table of Contents\n- [Table of Contents](#table-of-contents)\n- [DeepFusion Framework](#deepfusion-framework)\n- [Basic Usage](#basic-usage)\n- [Highlights](#highlights)\n  - [1. Customizable training](#1-customizable-training)\n  - [2. Gradient Checking](#2-gradient-checking)\n- [Installation](#installation)\n  - [1. Basic Installation](#1-basic-installation)\n  - [2. GPU Training](#2-gpu-training)\n  - [3. Network Visualization](#3-network-visualization)\n  - [4. All Dependencies](#4-all-dependencies)\n- [Resources](#resources)\n- [Contribution Guidelines](#contribution-guidelines)\n- [License](#license)\n- [Acknowledgements](#acknowledgements)\n- [Credits](#credits)\n\n\n## DeepFusion Framework\nIn DeepFusion, all networks are composed by combining 3 basic types of `components`:\n- `Data`\n- `Module`\n- `Net`\n\n`Data` objects hold the network activations and `Module` objects perform operations on them. The\n`Net` object forms a thin wrapper around the `Data` and `Module` objects and is used to perform\nthe forward and backward passes.\n\nA simple neural network is shown below, where, ellipses represent `Data` objects and rectangles\nrepresent `Module`.\n\n![Basic Neural Network](https://raw.githubusercontent.com/atharvaaalok/deepfusion/main/assets/readme_assets/Basic_NeuralNetwork.svg)\n\n\u003e Note the alternating sequence of `Data` and `Module`. The scheme is `Data` -\u003e `Module` -\u003e `Data`.\n\u003e Red represents nodes with updatable parameters.\n\nEvery node (`Data` or `Module`) has a unique *ID* (for eg: z1 or MatMul1) using which it can be\naccessed and modified thus providing explicit access and control over all data and parameters.\n\nMore details on `Data`, `Module` and `Net` functionalities can be found in their respective readmes\nin [deepfusion/components](./deepfusion/components/).\n\nThis is the basic idea behind deepfusion and any and all neural networks are created using this\nprocedure of attaching alternating `Data` and `Module` nodes.\n\n\n## Basic Usage\nAs described before, in DeepFusion, all networks are composed by combining 3 basic types of\n`components`:\n- `Data`\n- `Module`\n- `Net`\n\nThe codebase follows the same intuitive structure:\n```\ndeepfusion\n└── components\n    ├── net\n    ├── data\n    └── modules\n        ├── activation_functions\n        ├── loss_functions\n        └── matmul.py\n```\n\nTo construct a neural network we need to import the `Net`, `Data` and required `Module` objects.\n```python\n# Import Net, Data and necessary Modules\nfrom deepfusion.components.net import Net\nfrom deepfusion.components.data import Data\nfrom deepfusion.components.modules import MatMul\nfrom deepfusion.components.modules.activation_functions import Relu\nfrom deepfusion.components.modules.loss_functions import MSELoss\n```\n\u003e The codebase is designed in an intuitive manner. Let's see how we would think about the above\n\u003e imports. \"Okay, to create a neural network I need components (deepfusion.components). What kind of\n\u003e components do we need? Net, Data and Modules (import these). What kind of modules (operations) do\n\u003e we need? we need matrix multiplication, an activation function and a loss function (import these).\n\u003e That's it!\"\n\nTo connect `Data` and `Module` objects we need to keep in mind the following 2 things:\n- `Data` objects are used to specify the activation *dimensions*.\n- `Module` objects require the *inputs* and *output* data objects to be specified.\n\n\nNow, let's construct the simple network we saw above.\n```python\n# Basic structure: x -\u003e Matmul -\u003e z1 -\u003e Relu -\u003e a -\u003e Matmul -\u003e z2, + y -\u003e MSE -\u003e loss\nx = Data(ID = 'x', shape = (1, 3))\n\nz1 = Data(ID = 'z1', shape = (1, 5))\nMatmul1 = MatMul(ID = 'Matmul1', inputs = [x], output = z1)\n\na = Data(ID = 'a', shape = (1, 5))\nActF = Relu(ID = 'ActF', inputs = [z1], output = a)\n\nz2 = Data(ID = 'z2', shape = (1, 1))\nMatmul2 = MatMul(ID = 'Matmul2', inputs = [a], output = z2)\n\n# Add target variable, loss variable and loss function\ny = Data('y', shape = (1, 1))\nloss = Data('loss', shape = (1, 1))\nLossF = MSELoss(ID = 'LossF', inputs = [z2, y], output = loss)\n\n# Initialize the neural network\nnet = Net(ID = 'Net', root_nodes = [loss])\n```\n\u003e For `Data` the first dimension is the batch size. This is specified 1 during initialization. Eg:\n\u003e a length 3 vector would have shape = (1, 3) and a conv volume (C, H, W) would have shape =\n\u003e (1, C, H, W). During training any batch size (B, 3) or (B, C, H, W) can be used, the `Net` object\n\u003e takes care of it.\n\n\u003e Module parameter dimensions are inferred from connected data objects.\n\nExamples introducing the basics and all features of the library can be found in the [demo](./demo/)\ndirectory or in other [resources](#resources).\n\nTo have a look at the codebase tree have a look at [Codebase Tree](./assets/codebase_tree.txt).\n\n\n## Highlights\n### 1. Customizable training\nLet's say we make the simple neural network as before:\n\n![Basic Neural Network](https://raw.githubusercontent.com/atharvaaalok/deepfusion/main/assets/readme_assets/Basic_NeuralNetwork.svg)\nAnd train it. During training only the *red* portions of the network receive updates and are\ntrained. Therefore, the matrix multiplication modules will be trained.\n\nLet's say we have trained the network and now we want to find the input that optimizes the function\nthat we have learnt. This also falls under the same forward-backward-update procedure with the\nfollowing simple twist:\n```python\nnet.freeze() # Freezes all modules\nx.unfreeze() # Unfreezes the input node\n```\nAfter this we obtain the following network:\n\n![Basic Neural Network](https://raw.githubusercontent.com/atharvaaalok/deepfusion/main/assets/readme_assets/Basic_NN_unfrozen_input.svg)\nNow when we train the network only the input node value will get updates and be trained!\n\n### 2. Gradient Checking\nWhen developing new modules, the implementation of the backward pass can often be tricky and have\nsubtle bugs. Deepfusion provides a gradient checking utility that can find the derivatives of the\nloss function(s) w.r.t. any specified data object (data node or module parameter). Eg:\n```python\n# Compare analytic and numeric gradients with a step size of 1e-6 for:\n# Input node: x\ngradient_checker(net, data_obj = x, h = 1e-6)\n# Matrix multiplication parameter W\ngradient_checker(net, data_obj = Matmul1.W, h = 1e-6)\n```\n\n\u003e [!NOTE]\n\u003e Other features such as forward and backward pass profiling, multiple loss functions, automated\n\u003e training, gpu training etc. can be found in the [demo](./demo/) directory or in other\n\u003e [resources](#resources).\n\n\n## Installation\n\n### 1. Basic Installation  \nTo install the core part of deepfusion use:\n```\n$ pip install deepfusion\n```\n\n### 2. GPU Training\nTo use GPU training capabilities you will require [CuPy](https://pypi.org/project/cupy/) which\nneeds the [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit). If the CUDA Toolkit is\ninstalled then use:\n```\n$ pip install deepfusion[gpu]\n```\n\n### 3. Network Visualization\nFor visualizing networks you will require the [Graphviz](https://graphviz.org/download/) software\nand the [graphviz](https://pypi.org/project/graphviz/) package. If Graphviz is installed then use:\n```\n$ pip install deepfusion[visualization]\n```\n### 4. All Dependencies\nIf all dependencies are pre-installed use:\n```\npip install deepfusion[gpu,visualization]\n```\n\n\u003e [!IMPORTANT]\n\u003e Make sure to select add to PATH options when downloading dependency softwares.\n\n\n## Resources\n- [DeepFusion documentation]()\n- [DeepFusion demo](./demo/)\n- [DeepFusion Tutorials](https://github.com/atharvaaalok/deepfusion-examples)\n\n\n## Contribution Guidelines\nContributions for the following are encouraged and greatly appreciated:\n- **Code Optimization:** Benchmark your results and show a clear improvement.\n- **Visualization:** Currently requires graphviz which is usually a pain to install. Structured\n  graph visualization using say matplotlib would be a clear win.\n- **More Modules:** Most scope for contribution currently in the following modules: loss_functions,\n  pooling, normalizations, RNN modules etc.\n- **More Features:** Some ideas include adding multiprocessing, working with pre-trained models from\n  other libraries etc.\n- **Testing:** Incorporating testing codes.\n- **Improving Documentation:** Improving doc-string clarity and including doc tests. Also perhaps\n  making a website for API reference.\n\nWe'll use [Github issues](https://github.com/atharvaaalok/deepfusion/issues) for tracking pull\nrequests and bugs.\n\n\n## License\nDistributed under the [MIT License](License).\n\n\n## Acknowledgements\nTheoretical and code ideas inspired from:\n- [CS231n: Deep Learning for Computer Vision](https://cs231n.stanford.edu/)\n- [Coursera: Deep Learning Specialization](https://www.coursera.org/specializations/deep-learning)\n- [Google Python Style Guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md)\n- [Udemy: Python Packaging](https://www.udemy.com/course/python-packaging/?couponCode=LEADERSALE24B)\n\n\n## Credits\n- Logo design by [Ankur Tiwary](https://github.com/ankurTiwxry)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatharvaaalok%2Fdeepfusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatharvaaalok%2Fdeepfusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatharvaaalok%2Fdeepfusion/lists"}