A dynamic dataset loader for PyTorch.
Project description
Valtra (Validation - Train)
Valtra is a mini-project I created because I got sick of keeping track of train and validation/test datasets separately.
It dynamically switches between training and validation/test data using a simple wrapper around PyTorch’s DataLoader.
📌 Why "Valtra"?
The name comes from Validation and Train. Plus, it has a nice ring to it.
🚀 Installation
pip install valtra
🔧 Usage
import torch
from valtra.dataloader import DynamicDataLoader
from valtra.utils import split_dataset
# Create dummy data
data = torch.randn(1000, 10)
labels = torch.randint(0, 5, (1000,))
dataset = torch.utils.Dataset(data, labels)
# Create DynamicDataLoader
dataloader = split_dataset(dataset, split_ratio=0.8, batch_size=32)
# Training loop (default behavior is training mode)
for batch in dataloader(train=True):
print("Train batch:", batch[0].shape)
# Evaluation loop
for batch in dataloader(test=True):
print("Test batch:", batch[0].shape)
# Evaluation loop
for batch in dataloader(other=True):
print("Other batch:", batch[0].shape)
Contribution
There are many ways to make code more readable in torch. If you have another idea feel free to contact me or create an issue!
📜 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file valtra-0.1.0.tar.gz.
File metadata
- Download URL: valtra-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a847021d204e23150cd8277e36c8e0f1d3591ed90fb26c1faf731e9ac533fbca
|
|
| MD5 |
97a41174a61278cf03988a0e56662403
|
|
| BLAKE2b-256 |
9adb593dd997a8357d0b65aa72408cfbf389968f94ebc84b799ff6629afa152b
|
File details
Details for the file valtra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: valtra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42b0e9d5329c2e8337ce40a570e67bec90bb9b541465d7d641d0cfeeeea529ad
|
|
| MD5 |
7ee83f88fc433bd71f9290c5ec817444
|
|
| BLAKE2b-256 |
c0ffad33a38f1f3c617a9729276de54032b4b651567ba701398ae9e25de6ad61
|