Skip to main content

Helpful utilities for working with PyTorch.

Project description

torch-stuff

A collection of useful PyTorch utilities and dataset helpers.

Installation

pip install torch-stuff

Features

DelegatingSubset

A PyTorch dataset subset class that properly delegates all dataset attributes to the underlying dataset. This is particularly useful when working with datasets that have custom attributes that need to be preserved when creating subsets.

from torch_stuff.dataset import DelegatingSubset
from torch.utils.data import Dataset

# Create your dataset
class MyDataset(Dataset):
    def __init__(self):
        self.data = torch.randn(100, 3, 32, 32)
        self.targets = torch.randint(0, 10, (100,))
        self.classes = ['class1', 'class2', 'class3']  # Custom attribute
    
    def __len__(self):
        return len(self.data)
    
    def __getitem__(self, idx):
        return self.data[idx], self.targets[idx]

# Create a subset that preserves all attributes
dataset = MyDataset()
subset = DelegatingSubset(dataset, indices=[0, 1, 2, 3])

# Access custom attributes from the subset
print(subset.classes)  # ['class1', 'class2', 'class3']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torch_things-0.0.6.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torch_things-0.0.6-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file torch_things-0.0.6.tar.gz.

File metadata

  • Download URL: torch_things-0.0.6.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for torch_things-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ec7156d0da10e91228ad0afaaf888084bef6460c5a808f39564f097da756a962
MD5 3eeaae9817a0e0e2e54112c2c566207e
BLAKE2b-256 ab48dc8e0f2379f09ebc487f900ed68541068e12efc926b12330c1aa622c6d97

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_things-0.0.6.tar.gz:

Publisher: publish.yml on dwahdany/torch-stuff

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_things-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: torch_things-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for torch_things-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8b76e7ee66a3997037a8f15d34808b13277823ca7feabddaac69751b748fa9ab
MD5 b65419d814a9019efd7ef84aee4a2b70
BLAKE2b-256 60241919c121b8a605711486c74128aa7bd4ccd30023ff3a70a0ecd4cf4d6180

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_things-0.0.6-py3-none-any.whl:

Publisher: publish.yml on dwahdany/torch-stuff

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page