{ "info": { "author": "Anjandeep Singh Sahni", "author_email": "sahni.anjandeep@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "==========\nTorchUtils\n==========\n\n.. image:: https://badge.fury.io/py/torchutils.svg\n :target: https://badge.fury.io/py/torchutils\n\n.. image:: https://travis-ci.org/anjandeepsahni/pytorch_utils.svg?branch=master\n :target: https://travis-ci.org/anjandeepsahni/pytorch_utils\n\n|\n\n**TorchUtils** is a Python package providing helpful utility functions for your\nPyTorch projects. TorchUtils helps speed up PyTorch development by implementing\ntrivial but useful functionality so that you don't have to.\n\nKey Features\n------------\n\n* Calculate total model parameters.\n* Calculate model FLOPs.\n* Print model summary in Keras style.\n* Save/load checkpoints.\n* Get/set learning rate.\n* Set random seed.\n\nExamples\n--------\n\nModel Summary::\n\n import torch\n import torchvision\n import torchutils as tu\n\n model = torchvision.models.alexnet()\n tu.get_model_summary(model, torch.rand((1, 3, 224, 224)))\n\n # Output\n\n =========================================================================================\n Layer Kernel Output Params FLOPs\n =========================================================================================\n 0_features.Conv2d_0 [3, 64, 11, 11] [1, 64, 55, 55] 23,296 70,470,400\n 1_features.ReLU_1 - [1, 64, 55, 55] 0 0\n 2_features.MaxPool2d_2 - [1, 64, 27, 27] 0 0\n 3_features.Conv2d_3 [64, 192, 5, 5] [1, 192, 27, 27] 307,392 224,088,768\n 4_features.ReLU_4 - [1, 192, 27, 27] 0 0\n 5_features.MaxPool2d_5 - [1, 192, 13, 13] 0 0\n 6_features.Conv2d_6 [192, 384, 3, 3] [1, 384, 13, 13] 663,936 112,205,184\n 7_features.ReLU_7 - [1, 384, 13, 13] 0 0\n 8_features.Conv2d_8 [384, 256, 3, 3] [1, 256, 13, 13] 884,992 149,563,648\n 9_features.ReLU_9 - [1, 256, 13, 13] 0 0\n 10_features.Conv2d_10 [256, 256, 3, 3] [1, 256, 13, 13] 590,080 99,723,520\n 11_features.ReLU_11 - [1, 256, 13, 13] 0 0\n 12_features.MaxPool2d_12 - [1, 256, 6, 6] 0 0\n 13_classifier.Dropout_0 - [1, 9216] 0 0\n 14_classifier.Linear_1 [9216, 4096] [1, 4096] 37,752,832 75,493,376\n 15_classifier.ReLU_2 - [1, 4096] 0 0\n 16_classifier.Dropout_3 - [1, 4096] 0 0\n 17_classifier.Linear_4 [4096, 4096] [1, 4096] 16,781,312 33,550,336\n 18_classifier.ReLU_5 - [1, 4096] 0 0\n 19_classifier.Linear_6 [4096, 1000] [1, 1000] 4,097,000 8,191,000\n =========================================================================================\n Total params: 61,100,840\n Trainable params: 61,100,840\n Non-trainable params: 0\n Total FLOPs: 773,286,232 / 773.29 MFLOPs\n -----------------------------------------------------------------------------------------\n Input size (MB): 0.57\n Forward/backward pass size (MB): 8.31\n Params size (MB): 233.08\n Estimated Total Size (MB): 241.96\n =========================================================================================\n\nLearning Rate::\n\n import torchvision\n import torchutils as tu\n import torch.optim as optim\n\n model = torchvision.models.alexnet()\n optimizer = optim.Adam(model.parameters())\n current_lr = tu.get_lr(optimizer)\n print('Current learning rate:', current_lr)\n\n optimizer = tu.set_lr(optimizer, current_lr*0.1)\n revised_lr = tu.get_lr(optimizer)\n print('Revised learning rate:', revised_lr)\n\n # Output\n\n Current learning rate: 0.001\n Revised learning rate: 0.0001\n\nCheckpoint::\n\n import torchvision\n import torchutils as tu\n import torch.optim as optim\n\n model = torchvision.models.alexnet()\n optimizer = optim.Adam(model.parameters())\n scheduler = optim.lr_scheduler.ExponentialLR(optimizer, 0.1)\n\n print('Original learning rate:', tu.get_lr(optimizer))\n\n # load checkpoint model_20190814-212442_e0_0.7531.pt\n start_epoch = tu.load_checkpoint(model_path='.',\n ckpt_name='model_20190814-212442_e0_0.7531.pt',\n model=model, optimizer=optimizer,\n scheduler=scheduler)\n\n print('Checkpoint learning rate:', tu.get_lr(optimizer))\n print('Start from epoch:', start_epoch)\n\n # Output\n\n Original learning rate: 0.001\n Checkpoint learning rate: 0.1234\n Start epoch: 1\n\nRequirements\n------------\n\n* Numpy >= 1.16.2\n* PyTorch >= 1.0.0\n\nInstallation\n------------\n\n::\n\n $ pip install torchutils\n\nDocumentation\n-------------\nAPI documentation is available at: https://anjandeepsahni.github.io/torchutils/\n\nLicense\n-------\nTorchUtils is distributed under the MIT license, see LICENSE.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/anjandeepsahni/pytorch_utils", "keywords": "machine-learning deep-learning pytorch neuralnetwork", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "torchutils", "package_url": "https://pypi.org/project/torchutils/", "platform": "", "project_url": "https://pypi.org/project/torchutils/", "project_urls": { "Homepage": "https://github.com/anjandeepsahni/pytorch_utils" }, "release_url": "https://pypi.org/project/torchutils/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "PyTorch utility functions.", "version": "0.0.2" }, "last_serial": 5725928, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "965275ca87e9bdad0d7eb17e5df13509", "sha256": "6447289cc9c630f393f4368536698cb41a3c9e86fbbedae6e4445dc7ecd67995" }, "downloads": -1, "filename": "torchutils-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "965275ca87e9bdad0d7eb17e5df13509", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4687, "upload_time": "2019-07-20T00:47:48", "url": "https://files.pythonhosted.org/packages/da/81/e089225a52737e7f3551946d47ed7259e393dfcdf9121f74424caa6d7e3e/torchutils-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c59384fb8e0243c9b1b8263840eef6aa", "sha256": "3118932cb9f854dc6b0591e9c17a856a7f390530ca1cb94eb51373dc7fe7dbc3" }, "downloads": -1, "filename": "torchutils-0.0.1.tar.gz", "has_sig": false, "md5_digest": "c59384fb8e0243c9b1b8263840eef6aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2587, "upload_time": "2019-07-20T00:47:50", "url": "https://files.pythonhosted.org/packages/66/30/3f2412f104da2d654a29ba536f758592202c3bb5d780d6730047cb1bea47/torchutils-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "ba08ab71d6ec36c04b4750f5176216d1", "sha256": "c6bfac7a2a0c7d44982b6c946c4df5f778a99f560fef73ec4cd1980b7294501c" }, "downloads": -1, "filename": "torchutils-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "ba08ab71d6ec36c04b4750f5176216d1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14275, "upload_time": "2019-08-25T03:38:19", "url": "https://files.pythonhosted.org/packages/56/49/e3ca846d4c7862d79200dd9a03fee40a023e1c83f7bb73aa1fde1ec46920/torchutils-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aef54b6816e4190ca828153f52b7ae97", "sha256": "fb63a2f4fa98ddda5efe267d9cba934dd1121e8d6acf95518fd7f8bf3bc5ca37" }, "downloads": -1, "filename": "torchutils-0.0.2.tar.gz", "has_sig": false, "md5_digest": "aef54b6816e4190ca828153f52b7ae97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10532, "upload_time": "2019-08-25T03:38:21", "url": "https://files.pythonhosted.org/packages/39/18/44bf3e2ca4011aae3487ca1bbad3f580db74e462da28e8fbe91060f13749/torchutils-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ba08ab71d6ec36c04b4750f5176216d1", "sha256": "c6bfac7a2a0c7d44982b6c946c4df5f778a99f560fef73ec4cd1980b7294501c" }, "downloads": -1, "filename": "torchutils-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "ba08ab71d6ec36c04b4750f5176216d1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14275, "upload_time": "2019-08-25T03:38:19", "url": "https://files.pythonhosted.org/packages/56/49/e3ca846d4c7862d79200dd9a03fee40a023e1c83f7bb73aa1fde1ec46920/torchutils-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aef54b6816e4190ca828153f52b7ae97", "sha256": "fb63a2f4fa98ddda5efe267d9cba934dd1121e8d6acf95518fd7f8bf3bc5ca37" }, "downloads": -1, "filename": "torchutils-0.0.2.tar.gz", "has_sig": false, "md5_digest": "aef54b6816e4190ca828153f52b7ae97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10532, "upload_time": "2019-08-25T03:38:21", "url": "https://files.pythonhosted.org/packages/39/18/44bf3e2ca4011aae3487ca1bbad3f580db74e462da28e8fbe91060f13749/torchutils-0.0.2.tar.gz" } ] }