{ "info": { "author": "Somshubra Majumdar", "author_email": "titu1994@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "\n# EfficientNets in Keras\n[![Build Status](https://travis-ci.org/titu1994/keras-efficientnets.svg?branch=master)](https://travis-ci.org/titu1994/keras-efficientnets)\n\nKeras implementation of EfficientNets from the paper [EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks](https://arxiv.org/abs/1905.11946).\n\nContains code to build the EfficientNets B0-B7 from the paper, and includes weights for configurations B0-B3. B4-B7 weights will be ported when made available from the Tensorflow repository.\n\nSupports building any other configuration model of efficient nets as well, other than the B0-B7 variants.\n\n# Efficient Nets and Compound Coefficeint Scaling \nThe core idea about Efficient Nets is the use of compound scaling - using a weighted scale of three inter-connected hyper parameters of the model - Resolution of the input, Depth of the Network and Width of the Network.\n\n

\n\n

\n\nWhen `phi`, the compound coefficient, is initially set to 1, we get the base configuration - in this case `EfficientNetB0`. We then use this configuration in a grid search to find the coefficients `alpha`, `beta` and `gamma` which optimize the following objective under the constraint:\n\n

\n\n

\n\nOnce these coefficients for `alpha`, `beta` and `gamma` are found, then simply scale `phi`, the compound coeffieints by different amounts to get a family of models with more capacity and possibly better performance.\n\n-----\n\nIn doing so, and using Neural Architecture Search to get the base configuration as well as great coefficients for the above, the paper generates EfficientNets, which outperform much larger and much deeper models while using less resources during both training and evaluation.\n\n \n\n# Installation\n\n## From PyPI:\n\n```$ pip install keras_efficientnets```\n\n## From Master branch:\n\n```\npip install git+https://github.com/titu1994/keras-efficientnets.git\n\nOR\n\ngit clone https://github.com/titu1994/keras-efficientnets.git\ncd keras-efficientnets\npip install .\n```\n\n# Usage\nSimply import `keras_efficientnets` and call either the model builder `EfficientNet` or the pre-built versions `EfficientNetBX` where `X` ranger from 0 to 7.\n\n```python\nfrom keras_efficientnets import EfficientNetB0\n\nmodel = EfficientNetB0(input_size, classes=1000, include_top=True, weights='imagenet')\n```\n\nTo construct custom EfficientNets, use the `EfficientNet` builder. The `EfficientNet` builder code requires a list of `BlockArgs`\nas input to define the structure of each block in model. A default set of `BlockArgs` are provided in `keras_efficientnets.config`.\n\n```python\nfrom keras_efficientnets import EfficientNet, BlockArgs\n\nblock_args_list = [\n # First number is `input_channels`, second is `output_channels`.\n BlockArgs(32, 16, kernel_size=3, strides=(1, 1), num_repeat=1, se_ratio=0.25, expand_ratio=1),\n BlockArgs(16, 24, kernel_size=3, strides=(2, 2), num_repeat=2, se_ratio=0.25, expand_ratio=6),\n ...\n]\n\nmodel = EfficientNet(input_shape, block_args_list, ...)\n```\n\n# Computing Valid Compound Coefficients\nIn the paper, compound coefficients are obtained via simple grid search to find optimal values of `alpha`,\n`beta` and `gamma` while keeping `phi` as 1.\n\nThis library provides a utility function to compute valid candidates that satisfy a user defined criterion\nfunction (the one from the paper is provided as the default cost function), and quickly computes\nthe set of hyper parameters that closely satisfy the cost function (here, MSE between the value and max cost permissible).\n\nAn example is shown below which uses the default parameters from the paper. The user can change the number of coefficients\nas well as the cost function itself in order to get different values of the compound coefficients.\n\n```python\nfrom keras_efficientnets.optimize import optimize_coefficients\nfrom keras_efficientnets.optimize import get_compound_coeff_func\n\nresults = optimize_coefficients(phi=1., max_cost=2.0, search_per_coeff=10)\ncost_func = get_compound_coeff_func(phi=1.0, max_cost=2.0)\n\nprint(\"Num unique configs = \", len(results))\nfor i in range(10): # print just the first 10 results out of 1000 results\n print(i + 1, results[i], \"Cost :\", cost_func(results[i]))\n```\n\nIncrease the number of search scopes using `search_per_coeff` to some larger int value. You could also combine this\nwith `tol` to compute a vast set of coefficients, and then select only those that have a cost value lower than the\nspecified tolerance.\n\n```python\nfrom keras_efficientnets.optimize import optimize_coefficients\nfrom keras_efficientnets.optimize import get_compound_coeff_func\n\nresults = optimize_coefficients(phi=1., max_cost=2.0, search_per_coeff=10, tol=1e-10)\ncost_func = get_compound_coeff_func(phi=1.0, max_cost=2.0)\n\nprint(\"Num unique configs = \", len(results))\nfor i in range(10): # print just the first 10 results out of 125 results\n print(i + 1, results[i], \"Cost :\", cost_func(results[i]))\n```\n\n# Requirements\n- Tensorflow 1.13+ (CPU or GPU version must be installed *before* installation of this library)\n- Keras 2.2.4+\n\n# References\n```\n[1] Mingxing Tan and Quoc V. Le. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. ICML 2019. Arxiv link: https://arxiv.org/abs/1905.11946.\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/titu1994/keras-efficientnets", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/titu1994/keras-efficientnets", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "keras-efficientnets", "package_url": "https://pypi.org/project/keras-efficientnets/", "platform": "", "project_url": "https://pypi.org/project/keras-efficientnets/", "project_urls": { "Download": "https://github.com/titu1994/keras-efficientnets", "Homepage": "https://github.com/titu1994/keras-efficientnets" }, "release_url": "https://pypi.org/project/keras-efficientnets/0.1.7/", "requires_dist": [ "keras (>=2.2.4)", "scipy (>=1.1.0)", "scikit-learn (>=0.21.2)", "pytest ; extra == 'test'", "pillow ; extra == 'test'" ], "requires_python": ">=3.0.0", "summary": "Keras implementation of EfficientNets of any configuration.", "version": "0.1.7" }, "last_serial": 5947681, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "8273d670adbca58c183f3cac10980754", "sha256": "83e7a9030084c5c5d0cc71722bdbfbd44bb88e8cdfbc796334b5e2b8b11a9ef8" }, "downloads": -1, "filename": "keras_efficientnets-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8273d670adbca58c183f3cac10980754", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 12637, "upload_time": "2019-06-02T16:18:39", "url": "https://files.pythonhosted.org/packages/2c/ef/4100ab1ba51252784edc9f29c7f4295941797f9d67bb2e80cad08f4d914c/keras_efficientnets-0.1.0-py2.py3-none-any.whl" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4dc1de8019807800aef60604ad2061ab", "sha256": "1eecb1b559f04fcab2bf110ef8feea693cfaa024d5d09f4190804d2fe04a88c6" }, "downloads": -1, "filename": "keras_efficientnets-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4dc1de8019807800aef60604ad2061ab", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 12698, "upload_time": "2019-06-02T23:17:49", "url": "https://files.pythonhosted.org/packages/6e/37/f131a1a397d43b7ad559e9be1fbaab8e72c4bc9bcd0e994fdb48b86edd23/keras_efficientnets-0.1.1-py2.py3-none-any.whl" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "62bea5139b188c7d73204267a401c212", "sha256": "a92db779f79c722de7e259217775d0a4474fa64807fec57b74c5fee1a5e8926d" }, "downloads": -1, "filename": "keras_efficientnets-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "62bea5139b188c7d73204267a401c212", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 12703, "upload_time": "2019-06-04T03:03:04", "url": "https://files.pythonhosted.org/packages/6c/a7/10ec291e0d392307e6d1a914a76112e249b52faab5a511964365046ac713/keras_efficientnets-0.1.2-py2.py3-none-any.whl" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "59750eb69124f59ccdf64c0d80939864", "sha256": "2f7ca5967319e61b8573221d345ecf73b18b9df0991a62b320f4adac7e33166b" }, "downloads": -1, "filename": "keras_efficientnets-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "59750eb69124f59ccdf64c0d80939864", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 12700, "upload_time": "2019-06-05T01:32:53", "url": "https://files.pythonhosted.org/packages/57/e2/dcea60d66e2cad56f4ac10b12e57dabe22b9eb5d17c0851664afb75782e5/keras_efficientnets-0.1.3-py2.py3-none-any.whl" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "b500a087c43ff915ed4527c038dd76c0", "sha256": "a01a7259790645d76d7aef31655386c8753d27a8e43f26733acc367b749100ae" }, "downloads": -1, "filename": "keras_efficientnets-0.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b500a087c43ff915ed4527c038dd76c0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 12691, "upload_time": "2019-06-19T02:58:34", "url": "https://files.pythonhosted.org/packages/d7/58/53f5ad28afd1ed746e3d337fb39d3202bf521638a8cd2f3a49ac8042965e/keras_efficientnets-0.1.4-py2.py3-none-any.whl" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "b09153cdd132e7304cd4f3cbc7e4408f", "sha256": "b89e91792527afc71072fd77e623de783b6cf359d0668011085f772caf90c187" }, "downloads": -1, "filename": "keras_efficientnets-0.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b09153cdd132e7304cd4f3cbc7e4408f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 12712, "upload_time": "2019-06-28T23:25:46", "url": "https://files.pythonhosted.org/packages/6d/11/82d7dde9b976a58826de24847405c9a71eb890bb82d01c1315107b0e0470/keras_efficientnets-0.1.5-py2.py3-none-any.whl" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "75dcb384780964f03b991696ed8f684f", "sha256": "a6cd012c0f24e6516337ef5420d0d7ba40c463516c1aaf2796369258dbfe3791" }, "downloads": -1, "filename": "keras_efficientnets-0.1.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "75dcb384780964f03b991696ed8f684f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 15416, "upload_time": "2019-07-11T04:05:29", "url": "https://files.pythonhosted.org/packages/6d/da/afc4bbb39749a80d516c2808b9f3adb8dbfd2707159b8488ad4affa7ff34/keras_efficientnets-0.1.6-py2.py3-none-any.whl" } ], "0.1.6.1": [ { "comment_text": "", "digests": { "md5": "777d1e5582e886ce4c161f41aec57529", "sha256": "f302832d0002418e032335f87d25f2fc3991f0c99cb992beb21ccc2dc030dbe0" }, "downloads": -1, "filename": "keras_efficientnets-0.1.6.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "777d1e5582e886ce4c161f41aec57529", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 15434, "upload_time": "2019-07-11T04:20:08", "url": "https://files.pythonhosted.org/packages/cd/6e/657c05e837c80e9c2652f019715ec9c86bd0b6579c6801ca1742d65497b3/keras_efficientnets-0.1.6.1-py2.py3-none-any.whl" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "879d72d41218c32686e1fab3eb855f06", "sha256": "44230997e89ade54adc26c647b0e2817b055a0e257052a61c9fe582e8c56339d" }, "downloads": -1, "filename": "keras_efficientnets-0.1.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "879d72d41218c32686e1fab3eb855f06", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 15408, "upload_time": "2019-10-09T04:09:54", "url": "https://files.pythonhosted.org/packages/3a/41/4dce4e88042b4934003b2b51cfb6a99fc446d375d5fc1ffb2fdf8e069d36/keras_efficientnets-0.1.7-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "879d72d41218c32686e1fab3eb855f06", "sha256": "44230997e89ade54adc26c647b0e2817b055a0e257052a61c9fe582e8c56339d" }, "downloads": -1, "filename": "keras_efficientnets-0.1.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "879d72d41218c32686e1fab3eb855f06", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.0.0", "size": 15408, "upload_time": "2019-10-09T04:09:54", "url": "https://files.pythonhosted.org/packages/3a/41/4dce4e88042b4934003b2b51cfb6a99fc446d375d5fc1ffb2fdf8e069d36/keras_efficientnets-0.1.7-py2.py3-none-any.whl" } ] }