Skip to main content

Helpful utilities for working with PyTorch.

Project description

torch-things

A collection of useful PyTorch utilities and dataset helpers.

Installation

pip install torch-things

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_things.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.7.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.7-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_things-0.0.7.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.7.tar.gz
Algorithm Hash digest
SHA256 9ce726afd9637981603f799ee217f90b75b3bb3c3629d20613b0a4ac28a9c13e
MD5 3b6651f1882dc31cf53d655a478af950
BLAKE2b-256 cbecb32c06f2ca1ba7043079156bd875338f918f6491e6f8e04eef93501b064e

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on dwahdany/torch-things

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.7-py3-none-any.whl.

File metadata

  • Download URL: torch_things-0.0.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6324da686e1b5659c9c9c9fa5e340d12e038e89d2131105e2d9f7145edda6256
MD5 732f294defd778171e379d4212ec606e
BLAKE2b-256 c89efd67da4c03b28da94c4a35b607cbc0e422d404b064738184f674e2b4c7ed

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on dwahdany/torch-things

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