{ "info": { "author": "Tristan Deleu", "author_email": "tristan.deleu@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering :: Artificial Intelligence" ], "description": "# Torchmeta\n[![PyPI](https://img.shields.io/pypi/v/torchmeta)](https://pypi.org/project/torchmeta/) [![Build Status](https://travis-ci.com/tristandeleu/pytorch-meta.svg?branch=master)](https://travis-ci.com/tristandeleu/pytorch-meta) [![Documentation](https://img.shields.io/badge/docs-torchmeta-blue)](https://tristandeleu.github.io/pytorch-meta/)\n\nA collection of extensions and data-loaders for few-shot learning & meta-learning in [PyTorch](https://pytorch.org/). Torchmeta contains popular meta-learning benchmarks, fully compatible with both [`torchvision`](https://pytorch.org/docs/stable/torchvision/index.html) and PyTorch's [`DataLoader`](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader).\n\n#### Features\n - A unified interface for both few-shot classification and regression problems, to allow easy benchmarking on multiple problems and reproducibility.\n - Helper functions for some popular problems, with default arguments from the literature.\n - An thin extension of PyTorch's [`Module`](https://pytorch.org/docs/stable/nn.html#torch.nn.Module), called `MetaModule`, that simplifies the creation of certain meta-learning models (e.g. gradient based meta-learning methods). See the [MAML example](examples/maml) for an example using `MetaModule`.\n\n#### Datasets available\n - **Few-shot regression** (toy problems):\n - Sine waves ([Finn et al., 2017](https://arxiv.org/abs/1703.03400))\n - Harmonic functions ([Lacoste et al., 2018](https://arxiv.org/abs/1806.07528))\n - Sinusoid & lines ([Finn et al., 2018](https://arxiv.org/abs/1806.02817))\n - **Few-shot classification** (image classification):\n - Omniglot ([Lake et al., 2015](http://www.sciencemag.org/content/350/6266/1332.short)[, 2019](https://arxiv.org/abs/1902.03477))\n - Mini-ImageNet ([Vinyals et al., 2016](https://arxiv.org/abs/1606.04080), [Ravi et al., 2017](https://openreview.net/forum?id=rJY0-Kcll))\n - Tiered-ImageNet ([Ren et al., 2018](https://arxiv.org/abs/1803.00676))\n - CIFAR-FS ([Bertinetto et al., 2018](https://arxiv.org/abs/1805.08136))\n - Fewshot-CIFAR100 ([Oreshkin et al., 2018](https://arxiv.org/abs/1805.10123))\n\n## Installation\nYou can install Torchmeta either using Python's package manager pip, or from source. To avoid any conflict with your existing Python setup, it is suggested to work in a virtual environment with [`virtualenv`](https://docs.python-guide.org/dev/virtualenvs/). To install `virtualenv`:\n```bash\npip install --upgrade virtualenv\nvirtualenv venv\nsource venv/bin/activate\n```\n\n#### Requirements\n - Python 3.5 or above\n - PyTorch 1.2\n - Torchvision 0.4\n\n#### Using pip\nThis is the recommended way to install Torchmeta:\n```bash\npip install torchmeta\n```\n\n#### From source\nYou can also install Torchmeta from source. This is recommended if you want to contribute to Torchmeta.\n```bash\ngit clone https://github.com/tristandeleu/pytorch-meta.git\ncd pytorch-meta\npython setup.py install\n```\n\n## Example\n\n#### Minimal example\nThis minimal example below shows how to create a dataloader for the 5-shot 5-way Omniglot dataset with Torchmeta. The dataloader loads a batch of randomly generated tasks, and all the samples are concatenated into a single tensor. For more examples, check the [examples](examples/) folder.\n```python\nfrom torchmeta.datasets.helpers import omniglot\nfrom torchmeta.utils.data import BatchMetaDataLoader\n\ndataset = omniglot(\"data\", ways=5, shots=5, test_shots=15, meta_train=True, download=True)\ndataloader = BatchMetaDataLoader(dataset, batch_size=16, num_workers=4)\n\nfor batch in dataloader:\n train_inputs, train_targets = batch[\"train\"]\n print('Train inputs shape: {0}'.format(train_inputs.shape)) # (16, 25, 1, 28, 28)\n print('Train targets shape: {0}'.format(train_targets.shape)) # (16, 25)\n\n test_inputs, test_targets = batch[\"test\"]\n print('Test inputs shape: {0}'.format(test_inputs.shape)) # (16, 75, 1, 28, 28)\n print('Test targets shape: {0}'.format(test_targets.shape)) # (16, 75)\n```\n\n#### Advanced example\nHelper functions are only avaiable for some of the datasets available. However, all of them are available through the unified interface provided by Torchmeta. The variable `dataset` defined above is equivalent to the following\n```python\nfrom torchmeta.datasets import Omniglot\nfrom torchmeta.transforms import Categorical, ClassSplitter, Rotation\nfrom torchvision.transforms import Compose, Resize, ToTensor\nfrom torchmeta.utils.data import BatchMetaDataLoader\n\ndataset = Omniglot(\"data\",\n # Number of ways\n num_classes_per_task=5,\n # Resize the images to 28x28 and converts them to PyTorch tensors (from Torchvision)\n transform=Compose([Resize(28), ToTensor()]),\n # Transform the labels to integers (e.g. (\"Glagolitic/character01\", \"Sanskrit/character14\", ...) to (0, 1, ...))\n target_transform=Categorical(num_classes=5),\n # Creates new virtual classes with rotated versions of the images (from Santoro et al., 2016)\n class_augmentations=[Rotation([90, 180, 270])],\n meta_train=True,\n download=True)\ndataset = ClassSplitter(dataset, shuffle=True, num_train_per_class=5, num_test_per_class=15)\ndataloader = BatchMetaDataLoader(dataset, batch_size=16, num_workers=4)\n```\nNote that the dataloader, receiving the dataset, remains the same.\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/tristandeleu/pytorch-meta", "keywords": "meta-learning,pytorch,few-shot,few-shot learning", "license": "", "maintainer": "", "maintainer_email": "", "name": "torchmeta", "package_url": "https://pypi.org/project/torchmeta/", "platform": "", "project_url": "https://pypi.org/project/torchmeta/", "project_urls": { "Homepage": "https://github.com/tristandeleu/pytorch-meta" }, "release_url": "https://pypi.org/project/torchmeta/1.1.1/", "requires_dist": [ "torch (<1.3.0,>=1.2.0)", "torchvision (<0.5.0,>=0.4.0)", "numpy (>=1.14.0)", "Pillow (>=5.0.0)", "h5py (~=2.9.0)", "tqdm (>=4.0.0)", "requests", "pandas (~=0.24.0) ; extra == 'tcga'", "academictorrents (~=2.1.0) ; extra == 'tcga'", "six (~=1.11.0) ; extra == 'tcga'" ], "requires_python": "", "summary": "Dataloaders for meta-learning in Pytorch", "version": "1.1.1" }, "last_serial": 5838032, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "95c0dbe6c3a0446b20184e3ccc8ef469", "sha256": "e3870c06b07b866356ad2a8f298639271ada6bf17830e1ea401f5136ac6495e7" }, "downloads": -1, "filename": "torchmeta-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "95c0dbe6c3a0446b20184e3ccc8ef469", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 133039, "upload_time": "2019-09-16T12:59:29", "url": "https://files.pythonhosted.org/packages/42/6f/f80815de042a9e7d46b98f0c0921c4ddd5ad64137ab5bccd49e9833a743e/torchmeta-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2e64ef67b20f646fad57a0c5e9c05aae", "sha256": "8440e42f800409e589e3bc5f72da11156b4eda8a9c454bc55f611821e68f666f" }, "downloads": -1, "filename": "torchmeta-1.1.0.tar.gz", "has_sig": false, "md5_digest": "2e64ef67b20f646fad57a0c5e9c05aae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 108065, "upload_time": "2019-09-16T12:59:31", "url": "https://files.pythonhosted.org/packages/2c/ab/14c6aa941bfb943cdcfd8c336e5947eef6e8c65de7523d13eab446d91be0/torchmeta-1.1.0.tar.gz" } ], "1.1.0rc1": [ { "comment_text": "", "digests": { "md5": "162e3d6772093cc43743e226155ebdc0", "sha256": "711b8cf23d00c262ab7abb7f69669c903203d1031a738c3510e01344d576e6ad" }, "downloads": -1, "filename": "torchmeta-1.1.0rc1-py3-none-any.whl", "has_sig": false, "md5_digest": "162e3d6772093cc43743e226155ebdc0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 43348, "upload_time": "2019-08-16T10:40:49", "url": "https://files.pythonhosted.org/packages/d3/f4/6394a464a48d8f657533f34dfa2f8217edd6a92f55fc274981dfdb3f2dde/torchmeta-1.1.0rc1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "90fb65cebe22f5df32e8e59b10f9bb6e", "sha256": "6b602684c300fcaec6a92a0c4a8f89a07310e4506dd93524967d2e46c35a25af" }, "downloads": -1, "filename": "torchmeta-1.1.0rc1.tar.gz", "has_sig": false, "md5_digest": "90fb65cebe22f5df32e8e59b10f9bb6e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 104261, "upload_time": "2019-08-16T10:24:34", "url": "https://files.pythonhosted.org/packages/e1/49/5a937be6081a0776c4b0e1978d1ae42aecb1744cf30aaeb60d6d27a0b9df/torchmeta-1.1.0rc1.tar.gz" } ], "1.1.0rc2": [ { "comment_text": "", "digests": { "md5": "32d8dd96ab883ac944cf6ad774158ef3", "sha256": "ae54eb36c144c39e39253254d3a1a82662e063cc89d3ed02c0e1161fefaf9f21" }, "downloads": -1, "filename": "torchmeta-1.1.0rc2-py3-none-any.whl", "has_sig": false, "md5_digest": "32d8dd96ab883ac944cf6ad774158ef3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 129708, "upload_time": "2019-09-16T08:44:44", "url": "https://files.pythonhosted.org/packages/0b/d9/c07c041950869b933372beaf67a701c6f7b2d68091c649e65c365518c6ba/torchmeta-1.1.0rc2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "80736953eacb08f8ca6919456488eeb3", "sha256": "f53dba3b453e1d238be21539208585540b5046d0c38964f6907a9cb622df18b8" }, "downloads": -1, "filename": "torchmeta-1.1.0rc2.tar.gz", "has_sig": false, "md5_digest": "80736953eacb08f8ca6919456488eeb3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 105820, "upload_time": "2019-09-16T08:44:46", "url": "https://files.pythonhosted.org/packages/51/73/d250a3c5a5d90aed9bee806e5afbe0f4334d89e8ee91c3af6bd8e75a947c/torchmeta-1.1.0rc2.tar.gz" } ], "1.1.0rc8": [ { "comment_text": "", "digests": { "md5": "8a0f9ab2cac29425d8394cb5cb4b9aa2", "sha256": "56f09aa11281d8eb94a9dfc91b7f3ff41412f71ecb9ad2a0785ea96e685b9538" }, "downloads": -1, "filename": "torchmeta-1.1.0rc8-py3-none-any.whl", "has_sig": false, "md5_digest": "8a0f9ab2cac29425d8394cb5cb4b9aa2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 132671, "upload_time": "2019-09-16T12:02:43", "url": "https://files.pythonhosted.org/packages/d7/cd/bb7f6472f08c27968249c87f0423e56409940112261aca9f048c8d270199/torchmeta-1.1.0rc8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6f7f20cd5d56b1dc27e73c4e701e2508", "sha256": "8f90cdbd4c064ae1b4f350165f800429a88df1c1464ab99037fd8a137a9e9328" }, "downloads": -1, "filename": "torchmeta-1.1.0rc8.tar.gz", "has_sig": false, "md5_digest": "6f7f20cd5d56b1dc27e73c4e701e2508", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 107733, "upload_time": "2019-09-16T12:02:45", "url": "https://files.pythonhosted.org/packages/9b/3e/f4473d9b5bbcff50027ab4b79e89c373e44ece73ef0c3cd335539b466fe8/torchmeta-1.1.0rc8.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "80c0dd6856d79f18204e38dfc402e228", "sha256": "76a605f34eceef68404c784d21e01cb462879f8b5244e270a49e0826e477b204" }, "downloads": -1, "filename": "torchmeta-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "80c0dd6856d79f18204e38dfc402e228", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 133052, "upload_time": "2019-09-16T20:09:48", "url": "https://files.pythonhosted.org/packages/a9/15/007c1f2527f50fa25844afec7ca05f66be30bbc9a85a36d9c3e722a32705/torchmeta-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1fb15af43cd4083a334d81e1a0651b2", "sha256": "3ecb2a55c507dc091cb33d5318c31663125f1c5f459f1ea213b37d26bd00a4c8" }, "downloads": -1, "filename": "torchmeta-1.1.1.tar.gz", "has_sig": false, "md5_digest": "e1fb15af43cd4083a334d81e1a0651b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 108089, "upload_time": "2019-09-16T20:09:50", "url": "https://files.pythonhosted.org/packages/b3/96/857cec3acf16f6e205420c9cd971844db827f65afa3ab503ec3ec0a5d5b7/torchmeta-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "80c0dd6856d79f18204e38dfc402e228", "sha256": "76a605f34eceef68404c784d21e01cb462879f8b5244e270a49e0826e477b204" }, "downloads": -1, "filename": "torchmeta-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "80c0dd6856d79f18204e38dfc402e228", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 133052, "upload_time": "2019-09-16T20:09:48", "url": "https://files.pythonhosted.org/packages/a9/15/007c1f2527f50fa25844afec7ca05f66be30bbc9a85a36d9c3e722a32705/torchmeta-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1fb15af43cd4083a334d81e1a0651b2", "sha256": "3ecb2a55c507dc091cb33d5318c31663125f1c5f459f1ea213b37d26bd00a4c8" }, "downloads": -1, "filename": "torchmeta-1.1.1.tar.gz", "has_sig": false, "md5_digest": "e1fb15af43cd4083a334d81e1a0651b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 108089, "upload_time": "2019-09-16T20:09:50", "url": "https://files.pythonhosted.org/packages/b3/96/857cec3acf16f6e205420c9cd971844db827f65afa3ab503ec3ec0a5d5b7/torchmeta-1.1.1.tar.gz" } ] }