{ "info": { "author": "Szymon Maszke", "author_email": "szymon.maszke@protonmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "![torchfunc Logo](https://github.com/szymonmaszke/torchfunc/blob/master/assets/banner.png)\n\n--------------------------------------------------------------------------------\n\n| Version | Docs | Tests | Coverage | Style | PyPI | Python | PyTorch | Docker | Roadmap |\n|---------|------|-------|----------|-------|------|--------|---------|--------|---------|\n| [![Version](https://img.shields.io/static/v1?label=&message=0.1.1&color=377EF0&style=for-the-badge)](https://github.com/szymonmaszke/torchfunc/releases) | [![Documentation](https://img.shields.io/static/v1?label=&message=docs&color=EE4C2C&style=for-the-badge)](https://szymonmaszke.github.io/torchfunc/) | ![Tests](https://github.com/szymonmaszke/torchfunc/workflows/test/badge.svg) | ![Coverage](https://img.shields.io/codecov/c/github/szymonmaszke/torchfunc?label=%20&logo=codecov&style=for-the-badge) | [![codebeat](https://img.shields.io/static/v1?label=&message=CB&color=27A8E0&style=for-the-badge)](https://codebeat.co/projects/github-com-szymonmaszke-torchfunc-master) | [![PyPI](https://img.shields.io/static/v1?label=&message=PyPI&color=377EF0&style=for-the-badge)](https://pypi.org/project/torchfunc/) | [![Python](https://img.shields.io/static/v1?label=&message=3.7&color=377EF0&style=for-the-badge&logo=python&logoColor=F8C63D)](https://www.python.org/) | [![PyTorch](https://img.shields.io/static/v1?label=&message=1.2.0&color=EE4C2C&style=for-the-badge)](https://pytorch.org/) | [![Docker](https://img.shields.io/static/v1?label=&message=docker&color=309cef&style=for-the-badge)](https://cloud.docker.com/u/szymonmaszke/repository/docker/szymonmaszke/torchfunc) | [![Roadmap](https://img.shields.io/static/v1?label=&message=roadmap&color=009688&style=for-the-badge)](https://github.com/szymonmaszke/torchfunc/blob/master/ROADMAP.md) |\n\n[**torchfunc**](https://szymonmaszke.github.io/torchfunc/) is library revolving around [PyTorch](https://pytorch.org/) with a goal to help you with:\n\n\n* Improving and analysing performance of your neural network (e.g. Tensor Cores compatibility)\n* Record/analyse internal state of `torch.nn.Module` as data passes through it\n* Do the above based on external conditions (using single `Callable` to specify it)\n* Day-to-day neural network related duties (model size, seeding, performance measurements etc.)\n* Get information about your host operating system, CUDA devices and others\n\n# Quick examples\n\n- __Get instant performance tips about your module. All problems described by comments\nwill be shown by `torchfunc.performance.tips`:__\n\n```python\nclass Model(torch.nn.Module):\n def __init__(self):\n super().__init__()\n self.convolution = torch.nn.Sequential(\n torch.nn.Conv2d(1, 32, 3),\n torch.nn.ReLU(inplace=True), # Inplace may harm kernel fusion\n torch.nn.Conv2d(32, 128, 3, groups=32), # Depthwise is slower in PyTorch\n torch.nn.ReLU(inplace=True), # Same as before\n torch.nn.Conv2d(128, 250, 3), # Wrong output size for TensorCores\n )\n\n self.classifier = torch.nn.Sequential(\n torch.nn.Linear(250, 64), # Wrong input size for TensorCores\n torch.nn.ReLU(), # Fine, no info about this layer\n torch.nn.Linear(64, 10), # Wrong output size for TensorCores\n )\n\n def forward(self, inputs):\n convolved = torch.nn.AdaptiveAvgPool2d(1)(self.convolution(inputs)).flatten()\n return self.classifier(convolved)\n\n# All you have to do\nprint(torchfunc.performance.tips(Model()))\n```\n\n- __Seed globaly (including `numpy` and `cuda`), freeze weights, check inference time and model size:__\n\n```python\n# Inb4 MNIST, you can use any module with those functions\nmodel = torch.nn.Linear(784, 10)\ntorchfunc.seed(0)\nfrozen = torchfunc.module.freeze(model, bias=False)\n\nwith torchfunc.Timer() as timer:\n frozen(torch.randn(32, 784)\n print(timer.checkpoint()) # Time since the beginning\n frozen(torch.randn(128, 784)\n print(timer.checkpoint()) # Since last checkpoint\n\nprint(f\"Overall time {timer}; Model size: {torchfunc.sizeof(frozen)}\")\n```\n\n- __Record and sum per-layer activation statistics as data passes through network:__\n\n```python\n# Still MNIST but any module can be put in it's place\nmodel = torch.nn.Sequential(\n torch.nn.Linear(784, 100),\n torch.nn.ReLU(),\n torch.nn.Linear(100, 50),\n torch.nn.ReLU(),\n torch.nn.Linear(50, 10),\n)\n# Recorder which sums all inputs to layers\nrecorder = torchfunc.hooks.recorders.ForwardPre(reduction=lambda x, y: x+y)\n# Record only for torch.nn.Linear\nrecorder.children(model, types=(torch.nn.Linear,))\n# Train your network normally (or pass data through it)\n...\n# Activations of all neurons of first layer! \nprint(recorder[1]) # You can also post-process this data easily with apply\n```\n\nFor other examples (and how to use condition), see [documentation]()\n\n# Installation\n\n## [pip]()\n\n### Latest release:\n\n```shell\npip install --user torchfunc\n```\n\n### Nightly:\n\n```shell\npip install --user torchfunc-nightly\n```\n\n## [Docker](https://cloud.docker.com/repository/docker/szymonmaszke/torchfunc)\n\n__CPU standalone__ and various versions of __GPU enabled__ images are available\nat [dockerhub](https://cloud.docker.com/repository/docker/szymonmaszke/torchfunc).\n\nFor CPU quickstart, issue:\n\n```shell \ndocker pull szymonmaszke/torchfunc:18.04\n```\n\nNightly builds are also available, just prefix tag with `nightly_`. If you are going for `GPU` image make sure you have\n[nvidia/docker](https://github.com/NVIDIA/nvidia-docker) installed and it's runtime set.\n\n# Contributing\n\nIf you find any issue or you think some functionality may be useful to others and fits this library, please [open new Issue](https://help.github.com/en/articles/creating-an-issue) or [create Pull Request](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork).\n\nTo get an overview of things one can do to help this project, see [Roadmap](https://github.com/szymonmaszke/torchfunc/blob/master/ROADMAP.md).\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/szymonmaszke/torchfunc", "keywords": "pytorch torch functions performance visualize utils utilities recording", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "torchfunc", "package_url": "https://pypi.org/project/torchfunc/", "platform": "", "project_url": "https://pypi.org/project/torchfunc/", "project_urls": { "Documentation": "https://szymonmaszke.github.io/torchfunc/#torchfunc", "Homepage": "https://github.com/szymonmaszke/torchfunc", "Issues": "https://github.com/szymonmaszke/torchfunc/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc", "Website": "https://szymonmaszke.github.io/torchfunc" }, "release_url": "https://pypi.org/project/torchfunc/0.1.1/", "requires_dist": [ "torch (>=1.2.0)" ], "requires_python": ">=3.7", "summary": "PyTorch functions to improve performance, analyse models and make your life easier.", "version": "0.1.1" }, "last_serial": 5891254, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "efd8e6294896e46e06f6e12224ca29dd", "sha256": "b892eb9f8cda71aaa2636f3e3d360c23a4b3d5b1a481a98bb503243623bba561" }, "downloads": -1, "filename": "torchfunc-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "efd8e6294896e46e06f6e12224ca29dd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 24756, "upload_time": "2019-09-16T01:07:22", "url": "https://files.pythonhosted.org/packages/1f/ea/01db0b5e897861bc2423a9358a3a39d72473e562003e238ac19155b0b88c/torchfunc-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b8ba7494a919bff7d8b52dee7d518d7f", "sha256": "ea419e6f505d22a9a6dc7e696eabcccbd506d31287d1beedb6536729c8896ff9" }, "downloads": -1, "filename": "torchfunc-0.1.0.tar.gz", "has_sig": false, "md5_digest": "b8ba7494a919bff7d8b52dee7d518d7f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 19737, "upload_time": "2019-09-16T01:07:24", "url": "https://files.pythonhosted.org/packages/96/88/10d4353eccfc8416507243334dad3e452a7c09f2ea952cd7d09eeaba3a62/torchfunc-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "de0154fdb1f1144c10a3d547dddde3aa", "sha256": "6e97b24b21dca991d854d1d84ae66fa44eedb383c5d044115bdab60ddc782455" }, "downloads": -1, "filename": "torchfunc-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "de0154fdb1f1144c10a3d547dddde3aa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 28917, "upload_time": "2019-09-26T15:30:27", "url": "https://files.pythonhosted.org/packages/85/bc/f72e70a813bd40e23ef4206ed9df159b13c4a0c46488084da88b92c45362/torchfunc-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "503fe07507695f08e45b612840fa9b9d", "sha256": "8771d82842eb4138e4cfeb7c22a7f93233b126ec4b6889a4e20fea654fc8cee6" }, "downloads": -1, "filename": "torchfunc-0.1.1.tar.gz", "has_sig": false, "md5_digest": "503fe07507695f08e45b612840fa9b9d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 22582, "upload_time": "2019-09-26T15:30:29", "url": "https://files.pythonhosted.org/packages/8e/b1/f1666ebfdd4ddc4146b6dc406bd970a9a2c829b8e58c72422e88e4693b94/torchfunc-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "de0154fdb1f1144c10a3d547dddde3aa", "sha256": "6e97b24b21dca991d854d1d84ae66fa44eedb383c5d044115bdab60ddc782455" }, "downloads": -1, "filename": "torchfunc-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "de0154fdb1f1144c10a3d547dddde3aa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 28917, "upload_time": "2019-09-26T15:30:27", "url": "https://files.pythonhosted.org/packages/85/bc/f72e70a813bd40e23ef4206ed9df159b13c4a0c46488084da88b92c45362/torchfunc-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "503fe07507695f08e45b612840fa9b9d", "sha256": "8771d82842eb4138e4cfeb7c22a7f93233b126ec4b6889a4e20fea654fc8cee6" }, "downloads": -1, "filename": "torchfunc-0.1.1.tar.gz", "has_sig": false, "md5_digest": "503fe07507695f08e45b612840fa9b9d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 22582, "upload_time": "2019-09-26T15:30:29", "url": "https://files.pythonhosted.org/packages/8e/b1/f1666ebfdd4ddc4146b6dc406bd970a9a2c829b8e58c72422e88e4693b94/torchfunc-0.1.1.tar.gz" } ] }