https://github.com/FlorianDietz/comgra Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Customer Stories + White papers, Ebooks, Webinars + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} FlorianDietz / comgra Public * Notifications * Fork 1 * Star 48 License MIT license 48 stars 1 fork Activity Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights FlorianDietz/comgra This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/F] Use Git or checkout with SVN using the web URL. [gh repo clone Floria] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @FlorianDietz FlorianDietz . ... d33cf48 Sep 5, 2023 . d33cf48 Git stats * 121 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .run save and display metadata about the number of module parameters January 6, 2023 19:58 assets save and display metadata about the number of module parameters January 6, 2023 19:58 comgra number_to_hex(), coloring for tensor values September 3, 2023 13:44 notebooks . October 29, 2022 15:26 testing . September 3, 2023 14:08 .gitignore remove unneeded things September 3, 2023 13:14 LICENSE.txt . March 3, 2023 11:57 MANIFEST.in . March 3, 2023 11:57 README.md . September 5, 2023 10:22 comgra_screenshot.png . March 4, 2023 13:10 pyproject.toml . September 3, 2023 18:32 requirements.txt Preparing for publication March 2, 2023 20:55 setup.py . September 3, 2023 14:18 View code comgra Debugging Neural Networks more easily Installation Testing Usage Future Development README.md comgra Debugging Neural Networks more easily Comgra stands for "computation graph analysis". It is a library for use with pytorch that makes it easier to inspect the internals of your neural networks. Debugging neural architectures can be difficult, as the computation graphs are often very large and complex. This tool allows you to visualize the computation graph and inspect the values of individual tensors at different points in time. You can give names to tensors in your code, and they will be recorded and can be visualized graphically. This allows you to compare tensors as training proceeds. Tensors can be analyzed with different degrees of granularity depending on your needs. Inspect only KPIs across an entire batch, or drill down into the values of individual neurons on a single sample. You can also visualize which tensors are dependent on which other tensors, and track their gradients. This tool is especially helpful if you are developing new architectures and the architectures show unexpected behavior, as this visualization can help you understand what is going on much faster than the typical graph visualizations can do on their own. It is often useful to look at performance graphs of tensorboard or similar tools to identify which training steps have unexpected behavior, and then switch to comgra to inspect those steps in detail. See this screenshot for what the visualization looks like. Each rectangle is called a Node. They are clickable and each represents a tensor. The selection and sliders below specify which version of that tensor you want to inspect. The Nodes are causally connected, where the Nodes to the left appear earlier during computation and those to the right appear later. When you select a Node, all Nodes that are directly connected to it in the computation graph become highlighted with a border color (I have found that this is easier to read than actually drawing the connections as arrows once the number of Nodes grows large enough). Example screenshot of comgra Installation Run this to install: pip install comgra Testing Use the files in the 'testing' folder to run a basic ML model and visualize it. testing/run.py will create a folder to store recordings. testing/ server.py will open that folder and visualize it. In both cases, the --path argument can be used to change the default path to store data, which is in the directory where comgra is installed. Usage testing/run.py contains documentation for how to use comgra in your own code. If anything is unclear, I will be happy to answer any questions at floriandietz44@gmail.com The script takes two parameters: --path should be a folder where all your comgra results are stored. --name will be the name for this particular recording of comgra. A folder with this name will be created in --path, and it will overwrite previous results with the same name. You can visualize the results using the script in testing/server.py. This takes three parameters: --path should be a folder where all your comgra results are stored. --name is the name for the recording you want to display. --port is the port of localhost where the results will be displayed. Future Development A goal for the future development of this tool is the automated detection of anomalies in computational graphs. It should be possible to define anomalies like "Tensor X has a greater absolute value than 1" or the like, and then have the program automatically calculate likely dependencies such as this: The anomaly "abnormally high loss" has 87% correlation with the anomaly "Tensor 5 is close to zero". This would save a lot of time with debugging, by automatically generating a list of possible reasons for unexpected behavior. Anomalies could be defined in many different ways, and standard tools for causality analysis already exist. If you are interested in a feature like this and/or want to help, please let me know at floriandietz44@gmail.com About No description, website, or topics provided. Resources Readme License MIT license Activity Stars 48 stars Watchers 2 watching Forks 1 fork Report repository Releases No releases published Packages 0 No packages published Languages * Python 93.8% * Jupyter Notebook 6.0% * CSS 0.2% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.