https://github.com/dnbaker/tilt
Biased dataloaders for PyTorch and related utilities
https://github.com/dnbaker/tilt
Last synced: about 1 year ago
JSON representation
Biased dataloaders for PyTorch and related utilities
- Host: GitHub
- URL: https://github.com/dnbaker/tilt
- Owner: dnbaker
- Created: 2021-05-28T20:54:44.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-08T12:35:42.000Z (about 5 years ago)
- Last Synced: 2025-03-01T14:33:04.148Z (over 1 year ago)
- Language: Python
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simple biased samplers for PyTorch
For class-balanced samplers:
```python
from tilt import make_even_sampler, make_biased_sampler
sampler = make_even_sampler(labels) # Makes a class-balanced sampler
sampler = make_even_sampler(labels, idx=[1,4, 5]) # Makes a class-balanced sampler over the points 1, 4, 5
sampler = make_even_sampler(labels, nsamples=10000) # Makes a sampler with 10,000 samples
```
For class-balanced samplers:
```python
from tilt import make_even_sampler, make_biased_sampler
weights = np.abs(np.random.standard_cauchy((1000,)))
sampler = make_biased_sampler(weights, nsamples=100000)
```
Then, pass this as the sampler for PyTorch DataLoader construction.
In the future, I plan to add in contrastive learning mining utilities and autoaugmentation. For both of these, LSH techniques might come into play.