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

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_things-0.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 9eb71bba7e4a1359d3f67b18c3bb675c4353b5359c7ae14947df931544e413e8
MD5 37c0ae08826681acbba32ba4490b0ac3
BLAKE2b-256 3a45447f3c98180600a1a7b5267a3d2c1db89febfa1ed0e1711f095b4e0fa00f

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_things-0.0.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: torch_things-0.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1cfba877de10d3489335315ada2a7cfcd11c9f42edc55b2df0a5db02bfb33dc2
MD5 b3379534615ebe4ce95ffb774cf055a1
BLAKE2b-256 fd6e5a4d56033f555451a63941d8e40a9daa28b8d75b9608ff7dd30a8fbf450e

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_things-0.0.5-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