{ "info": { "author": "Miguel Varela Ramos", "author_email": "miguelvramos92@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# DropBlock\n\n![build](https://travis-ci.org/miguelvr/dropblock.png?branch=master)\n\n\nImplementation of [DropBlock: A regularization method for convolutional networks](https://arxiv.org/pdf/1810.12890.pdf) \nin PyTorch.\n\n## Abstract\n\nDeep neural networks often work well when they are over-parameterized \nand trained with a massive amount of noise and regularization, such as \nweight decay and dropout. Although dropout is widely used as a regularization \ntechnique for fully connected layers, it is often less effective for convolutional layers. \nThis lack of success of dropout for convolutional layers is perhaps due to the fact \nthat activation units in convolutional layers are spatially correlated so \ninformation can still flow through convolutional networks despite dropout. \nThus a structured form of dropout is needed to regularize convolutional networks. \nIn this paper, we introduce DropBlock, a form of structured dropout, where units in a \ncontiguous region of a feature map are dropped together. \nWe found that applying DropBlock in skip connections in addition to the \nconvolution layers increases the accuracy. Also, gradually increasing number \nof dropped units during training leads to better accuracy and more robust to hyperparameter choices. \nExtensive experiments show that DropBlock works better than dropout in regularizing \nconvolutional networks. On ImageNet classification, ResNet-50 architecture with \nDropBlock achieves 78.13% accuracy, which is more than 1.6% improvement on the baseline. \nOn COCO detection, DropBlock improves Average Precision of RetinaNet from 36.8% to 38.4%.\n\n\n## Installation\n\nInstall directly from PyPI:\n\n pip install dropblock\n\nor the bleeding edge version from github:\n\n pip install git+https://github.com/miguelvr/dropblock.git#egg=dropblock\n\n**NOTE**: Implementation and tests were done in Python 3.6, if you have problems with other versions of python please open an issue.\n\n## Usage\n\n\nFor 2D inputs (DropBlock2D):\n\n```python\nimport torch\nfrom dropblock import DropBlock2D\n\n# (bsize, n_feats, height, width)\nx = torch.rand(100, 10, 16, 16)\n\ndrop_block = DropBlock2D(block_size=3, drop_prob=0.3)\nregularized_x = drop_block(x)\n```\n\nFor 3D inputs (DropBlock3D):\n\n```python\nimport torch\nfrom dropblock import DropBlock3D\n\n# (bsize, n_feats, depth, height, width)\nx = torch.rand(100, 10, 16, 16, 16)\n\ndrop_block = DropBlock3D(block_size=3, drop_prob=0.3)\nregularized_x = drop_block(x)\n```\n\nScheduled Dropblock:\n\n```python\nimport torch\nfrom dropblock import DropBlock2D, LinearScheduler\n\n# (bsize, n_feats, depth, height, width)\nloader = [torch.rand(20, 10, 16, 16) for _ in range(10)]\n\ndrop_block = LinearScheduler(\n DropBlock2D(block_size=3, drop_prob=0.),\n start_value=0.,\n stop_value=0.25,\n nr_steps=5\n )\n\nprobs = []\nfor x in loader:\n drop_block.step()\n regularized_x = drop_block(x)\n probs.append(drop_block.dropblock.drop_prob)\n\nprint(probs)\n```\n\nThe drop probabilities will be:\n```\n>>> [0. , 0.0625, 0.125 , 0.1875, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25]\n```\n\nThe user should include the `step()` call at the start of the batch loop, \nor at the the start of a model's `forward` call. \n\nCheck [examples/resnet-cifar10.py](examples/resnet-cifar10.py) to\nsee an implementation example.\n\n## Implementation details\n\nWe use `drop_prob` instead of `keep_prob` as a matter of preference, \nand to keep the argument consistent with pytorch's dropout. \nRegardless, everything else should work similarly to what is described in the paper.\n\n## Benchmark\n\nRefer to [BENCHMARK.md](BENCHMARK.md)\n\n## Reference\n[Ghiasi et al., 2018] DropBlock: A regularization method for convolutional networks\n\n## TODO\n- [x] Scheduled DropBlock\n- [x] Get benchmark numbers\n- [x] Extend the concept for 3D images\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/miguelvr/dropblock", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "dropblock", "package_url": "https://pypi.org/project/dropblock/", "platform": "", "project_url": "https://pypi.org/project/dropblock/", "project_urls": { "Homepage": "https://github.com/miguelvr/dropblock" }, "release_url": "https://pypi.org/project/dropblock/0.3.0/", "requires_dist": [ "numpy", "torch (>=0.4.1)" ], "requires_python": "", "summary": "Implementation of DropBlock: A regularization method for convolutional networks in PyTorch.", "version": "0.3.0" }, "last_serial": 4607663, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "4a030bcd90e3803ed98179bf6cc2570b", "sha256": "36b14967a0eea52281dc4d74e2c445bffc3b61558b00966441a489f7f34712e9" }, "downloads": -1, "filename": "dropblock-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "4a030bcd90e3803ed98179bf6cc2570b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3088, "upload_time": "2018-11-04T12:10:14", "url": "https://files.pythonhosted.org/packages/42/e9/ea1afa72c7114685e6e971e23d68151eea00de171c2c7a6b9872c600be33/dropblock-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9795dcf790d7a5baa3a5e7160083040d", "sha256": "6c0865e3105bcca3ef0b42bd37cdea0706564c4a2c0bba074220dc48352c7985" }, "downloads": -1, "filename": "dropblock-0.1.0.tar.gz", "has_sig": false, "md5_digest": "9795dcf790d7a5baa3a5e7160083040d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2221, "upload_time": "2018-11-04T12:10:15", "url": "https://files.pythonhosted.org/packages/cd/ad/d72c8ed1843f80901a427aab178e34add52e0ac9bcd9a1047de83b70c93f/dropblock-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "60b353c2b1a65c2d81820e0b3baba05b", "sha256": "813611ae62c4eb13e7bfc6ea558899439628a61f12abdf2022b1618efa389364" }, "downloads": -1, "filename": "dropblock-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "60b353c2b1a65c2d81820e0b3baba05b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4186, "upload_time": "2018-11-14T13:38:43", "url": "https://files.pythonhosted.org/packages/9e/6d/517eecd0703ac51def8fcb14dd04d06164ad0179e32ab4eca1c02b0ffcb3/dropblock-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dc2daae1e373e655f1d16fd6488ce810", "sha256": "25eb2443e366ee35ddc03691384863fe2df2a3c4edfa0adf47b27f8ffdca822a" }, "downloads": -1, "filename": "dropblock-0.2.0.tar.gz", "has_sig": false, "md5_digest": "dc2daae1e373e655f1d16fd6488ce810", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3958, "upload_time": "2018-11-14T13:38:48", "url": "https://files.pythonhosted.org/packages/bf/07/df26f6f4e83c49b3a97c3014561a9777779630b6c05d97b8885456a4265f/dropblock-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "e479aabbaf64c72e0e16a6365ca08151", "sha256": "c03c8a4c7711fc05857e2b1454e1bde6a9d9254d69cc493ef99d819dbc2281d4" }, "downloads": -1, "filename": "dropblock-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e479aabbaf64c72e0e16a6365ca08151", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4178, "upload_time": "2018-11-29T10:31:44", "url": "https://files.pythonhosted.org/packages/49/90/cc210cad24e115c425fb084d730a812ce3609ffa3983b3a32b6dd29c55e6/dropblock-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4a6fe19d5f6ee98a6a3ba4b040f944d1", "sha256": "d7182e234bc26c2db90428661db53ae5dcf095baa7b52cd83d2c91c4d0fa1639" }, "downloads": -1, "filename": "dropblock-0.2.1.tar.gz", "has_sig": false, "md5_digest": "4a6fe19d5f6ee98a6a3ba4b040f944d1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3952, "upload_time": "2018-11-29T10:31:47", "url": "https://files.pythonhosted.org/packages/99/44/872486da099c5f11837a6ae85000b283fff70a7f2a24cb6af458e7861cf3/dropblock-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "c6903b9da76e5ca8355faca6b03f1d2f", "sha256": "98ce0a7c50f55ee31059e41b6d38cc6fd324eced729ac680265b00aafb1df0bf" }, "downloads": -1, "filename": "dropblock-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c6903b9da76e5ca8355faca6b03f1d2f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5373, "upload_time": "2018-12-17T11:45:56", "url": "https://files.pythonhosted.org/packages/92/ba/a2c6388f228045fa543f263923804e799b2e9d86b0517c5a53564ae0de3e/dropblock-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5a3e3d8d99b852fd1d5536d94ccd48f9", "sha256": "bdb016f36628ae69f0a4860614c84beb45873e5144a680485092485992a52617" }, "downloads": -1, "filename": "dropblock-0.3.0.tar.gz", "has_sig": false, "md5_digest": "5a3e3d8d99b852fd1d5536d94ccd48f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4111, "upload_time": "2018-12-17T11:45:58", "url": "https://files.pythonhosted.org/packages/f4/68/ccac0d2166ba6703bfcb4e1a19bb38f76cc677c70ccc85f1914167397f8b/dropblock-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c6903b9da76e5ca8355faca6b03f1d2f", "sha256": "98ce0a7c50f55ee31059e41b6d38cc6fd324eced729ac680265b00aafb1df0bf" }, "downloads": -1, "filename": "dropblock-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c6903b9da76e5ca8355faca6b03f1d2f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5373, "upload_time": "2018-12-17T11:45:56", "url": "https://files.pythonhosted.org/packages/92/ba/a2c6388f228045fa543f263923804e799b2e9d86b0517c5a53564ae0de3e/dropblock-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5a3e3d8d99b852fd1d5536d94ccd48f9", "sha256": "bdb016f36628ae69f0a4860614c84beb45873e5144a680485092485992a52617" }, "downloads": -1, "filename": "dropblock-0.3.0.tar.gz", "has_sig": false, "md5_digest": "5a3e3d8d99b852fd1d5536d94ccd48f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4111, "upload_time": "2018-12-17T11:45:58", "url": "https://files.pythonhosted.org/packages/f4/68/ccac0d2166ba6703bfcb4e1a19bb38f76cc677c70ccc85f1914167397f8b/dropblock-0.3.0.tar.gz" } ] }