{ "info": { "author": "CyberZHG", "author_email": "CyberZHG@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6" ], "description": "# Keras Adaptive Softmax\n\n[![Travis](https://travis-ci.org/CyberZHG/keras-adaptive-softmax.svg)](https://travis-ci.org/CyberZHG/keras-adaptive-softmax)\n[![Coverage](https://coveralls.io/repos/github/CyberZHG/keras-adaptive-softmax/badge.svg?branch=master)](https://coveralls.io/github/CyberZHG/keras-adaptive-softmax)\n[![Version](https://img.shields.io/pypi/v/keras-adaptive-softmax.svg)](https://pypi.org/project/keras-adaptive-softmax/)\n![Downloads](https://img.shields.io/pypi/dm/keras-adaptive-softmax.svg)\n![License](https://img.shields.io/pypi/l/keras-adaptive-softmax.svg)\n\n![](https://img.shields.io/badge/keras-tensorflow-blue.svg)\n![](https://img.shields.io/badge/keras-theano-blue.svg)\n![](https://img.shields.io/badge/keras-tf.keras-blue.svg)\n![](https://img.shields.io/badge/keras-tf.keras/eager-blue.svg)\n![](https://img.shields.io/badge/keras-tf.keras/2.0_beta-blue.svg)\n\n\\[[\u4e2d\u6587](https://github.com/CyberZHG/keras-adaptive-softmax/blob/master/README.zh-CN.md)|[English](https://github.com/CyberZHG/keras-adaptive-softmax/blob/master/README.md)\\]\n\n## Install\n\n```bash\npip install keras-adaptive-softmax\n```\n\n## Usage\n\nGenerally, `AdaptiveEmbedding` and `AdaptiveSoftmax` should be used together. `AdaptiveEmbedding` provides variable length embeddings, while `AdaptiveSoftmax` calculates the similarities between the outputs and the generated embeddings.\n\n```python\nimport keras\nfrom keras_adaptive_softmax import AdaptiveEmbedding, AdaptiveSoftmax\n\ninput_layer = keras.layers.Input(shape=(None,))\nembed_layer = AdaptiveEmbedding(\n input_dim=30,\n output_dim=32,\n cutoffs=[5, 15, 25],\n div_val=2,\n return_embeddings=True,\n return_projections=True,\n mask_zero=True,\n)(input_layer)\ndense_layer = keras.layers.Dense(\n units=32,\n activation='tanh',\n)(embed_layer[0])\nsoftmax_layer = AdaptiveSoftmax(\n input_dim=32,\n output_dim=30,\n cutoffs=[5, 15, 25],\n div_val=2,\n bind_embeddings=True,\n bind_projections=True,\n)([dense_layer] + embed_layer[1:])\nmodel = keras.models.Model(inputs=input_layer, outputs=softmax_layer)\nmodel.compile('adam', 'sparse_categorical_crossentropy')\nmodel.summary()\n```\n\n`cutoffs` and `div_val` controls the length of embeddings for each token. Suppose we have 30 distinct tokens, in the above example:\n\n* The lengths of the embeddings of the first 5 tokens are 32\n* The lengths of the embeddings of the next 10 tokens are 16\n* The lengths of the embeddings of the next 10 tokens are 8\n* The lengths of the embeddings of the last 5 tokens are 4", "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/CyberZHG/keras-adaptive-softmax", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "keras-adaptive-softmax", "package_url": "https://pypi.org/project/keras-adaptive-softmax/", "platform": "", "project_url": "https://pypi.org/project/keras-adaptive-softmax/", "project_urls": { "Homepage": "https://github.com/CyberZHG/keras-adaptive-softmax" }, "release_url": "https://pypi.org/project/keras-adaptive-softmax/0.6.0/", "requires_dist": null, "requires_python": "", "summary": "adaptive-softmax implemented in Keras", "version": "0.6.0" }, "last_serial": 5467511, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d295fb1b07ee57c88d7865cb20b193a6", "sha256": "6d521c3553e500bd2affd4152fd7ef8c7c5972c0a7589f4a74a5263f99ba9c47" }, "downloads": -1, "filename": "keras-adaptive-softmax-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d295fb1b07ee57c88d7865cb20b193a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15300, "upload_time": "2019-06-23T05:08:54", "url": "https://files.pythonhosted.org/packages/58/85/1a64e5afe91fdc82972b279deb67fc221681cf4818f50af05b9fdc4c011e/keras-adaptive-softmax-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "9fa32325220803a93a73a45d9836a9e8", "sha256": "eee76f94b82d81511345b4b38ac21c757d8bf340806ffbdfb5f41fc5a15c547a" }, "downloads": -1, "filename": "keras-adaptive-softmax-0.2.0.tar.gz", "has_sig": false, "md5_digest": "9fa32325220803a93a73a45d9836a9e8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15348, "upload_time": "2019-06-23T05:31:36", "url": "https://files.pythonhosted.org/packages/19/fb/600c7af6f567a962fdee35719d93ea8942e0ba08ec229a477a6bbda47ca2/keras-adaptive-softmax-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "3e4be394bc0e0ce32ef19478392d8f37", "sha256": "3389d1b2f4768171878cad694d09dd98548f4dc95239ba5235a351e25af7f80a" }, "downloads": -1, "filename": "keras-adaptive-softmax-0.2.1.tar.gz", "has_sig": false, "md5_digest": "3e4be394bc0e0ce32ef19478392d8f37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16052, "upload_time": "2019-06-23T09:34:53", "url": "https://files.pythonhosted.org/packages/f1/38/bc3882154eeedcb2f1eec6ed012125f360aeaab0694c7dff87fb27b07a83/keras-adaptive-softmax-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "13c0f1b803e53ff8d1f4fe503c6f2f8f", "sha256": "352ab8cfe9018d997147bd030d00b4876759a4aa7729025f5b21fe538632056e" }, "downloads": -1, "filename": "keras-adaptive-softmax-0.3.0.tar.gz", "has_sig": false, "md5_digest": "13c0f1b803e53ff8d1f4fe503c6f2f8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16317, "upload_time": "2019-06-26T07:46:39", "url": "https://files.pythonhosted.org/packages/c5/27/3ed5db39f747c92385838a581797f77f2073bba8cc512b6147213f4f3905/keras-adaptive-softmax-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "e55070f6e65d0705b450761f672b0e3b", "sha256": "5bf47e04abacfa4ef67d7bad04cfb6ea4a070f0edb735aa54b66495c465598f4" }, "downloads": -1, "filename": "keras-adaptive-softmax-0.4.0.tar.gz", "has_sig": false, "md5_digest": "e55070f6e65d0705b450761f672b0e3b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16049, "upload_time": "2019-06-30T08:19:59", "url": "https://files.pythonhosted.org/packages/19/30/1a7cebf70e9cb9cc79e5b05f22f64ff616d087e5327ed04561f3d4102e93/keras-adaptive-softmax-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "313bab6923b1d173602ccd5fb65acb69", "sha256": "d120787c047ab1cf401436a1c9b313e5fa3e23cc47fd4ff2e1258341e7ec1f4e" }, "downloads": -1, "filename": "keras-adaptive-softmax-0.5.0.tar.gz", "has_sig": false, "md5_digest": "313bab6923b1d173602ccd5fb65acb69", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16307, "upload_time": "2019-06-30T08:22:59", "url": "https://files.pythonhosted.org/packages/66/39/1e9c7120e11e822f0fdd70209157240b1f9b6495d6d3fba604a4a240edcf/keras-adaptive-softmax-0.5.0.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "3b8b88f027677ab274d57d1167e73a43", "sha256": "763e260c274002045cec33f2515eed0ad4fcd24d64c4a1b515b1a8889e05dfa7" }, "downloads": -1, "filename": "keras-adaptive-softmax-0.6.0.tar.gz", "has_sig": false, "md5_digest": "3b8b88f027677ab274d57d1167e73a43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16323, "upload_time": "2019-06-30T08:46:56", "url": "https://files.pythonhosted.org/packages/7b/7c/c58a76f3e9fdfb6252eaa18aac1dcbf011eac96c6de3adbb47db318567dd/keras-adaptive-softmax-0.6.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3b8b88f027677ab274d57d1167e73a43", "sha256": "763e260c274002045cec33f2515eed0ad4fcd24d64c4a1b515b1a8889e05dfa7" }, "downloads": -1, "filename": "keras-adaptive-softmax-0.6.0.tar.gz", "has_sig": false, "md5_digest": "3b8b88f027677ab274d57d1167e73a43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16323, "upload_time": "2019-06-30T08:46:56", "url": "https://files.pythonhosted.org/packages/7b/7c/c58a76f3e9fdfb6252eaa18aac1dcbf011eac96c6de3adbb47db318567dd/keras-adaptive-softmax-0.6.0.tar.gz" } ] }