Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

torchmeta

A collection of extensions and data-loaders for few-shot learning & meta-learning in PyTorch. The package contains popular meta-learning benchmarks, fully compatible with both torchvision and PyTorch's DataLoader.

Example

This 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. For more examples, check the examples folder.

from torchmeta.datasets import Omniglot
from torchmeta.transforms import Categorical, ClassSplitter
from torchvision.transforms import Resize, ToTensor, Compose

from torchmeta.utils.data import BatchMetaDataLoader

dataset = Omniglot('data', num_classes_per_task=5,
                   transform=Compose([Resize(28), ToTensor()]),
                   target_transform=Categorical(num_classes=5),
                   meta_train=True, download=True)
dataset = ClassSplitter(dataset, num_train_per_class=5, num_test_per_class=15)

dataloader = BatchMetaDataLoader(dataset, batch_size=16, num_workers=4)

for batch in dataloader:
    train_inputs, train_targets = batch['train']
    print('Train inputs shape: {0}'.format(train_inputs.shape))
    print('Train targets shape: {0}'.format(train_targets.shape))
    # Train inputs shape: torch.Size([16, 25, 1, 28, 28])
    # Train targets shape: torch.Size([16, 25])

    test_inputs, test_targets = batch['test']
    print('Test inputs shape: {0}'.format(test_inputs.shape))
    print('Test targets shape: {0}'.format(test_targets.shape))
    # Test inputs shape: torch.Size([16, 75, 1, 28, 28])
    # Test targets shape: torch.Size([16, 75])

Metadata

Release files for torchmeta 1.1.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchmeta 1.1.0rc1
File Size Uploaded
torchmeta-1.1.0rc1.tar.gz 104.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for torchmeta 1.1.0rc1
File Interpreter ABI Platform
torchmeta-1.1.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 147.6 kB

Release files / torchmeta-1.1.0rc1.tar.gz

Download URL torchmeta-1.1.0rc1.tar.gz
Size 104.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6b602684c300fcaec6a92a0c4a8f89a07310e4506dd93524967d2e46c35a25af
BLAKE2b-256 checksum
How to use checksums
e1495a937be6081a0776c4b0e1978d1ae42aecb1744cf30aaeb60d6d27a0b9df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.2

Release files / torchmeta-1.1.0rc1-py3-none-any.whl

Download URL torchmeta-1.1.0rc1-py3-none-any.whl
Size 43.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
711b8cf23d00c262ab7abb7f69669c903203d1031a738c3510e01344d576e6ad
BLAKE2b-256 checksum
How to use checksums
d3f46394a464a48d8f657533f34dfa2f8217edd6a92f55fc274981dfdb3f2dde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.2
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page