Metadata-Version: 2.1
Name: jaxonloader
Version: 0.1.5
Summary: A dataloader, but for JAX
Author-email: "Artur A. Galstyan" <mail@arturgalstyan.dev>
License: MIT License
        
        Copyright (c) 2024 Artur A. Galstyan
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: ~=3.10
Requires-Dist: beartype>=0.17.2
Requires-Dist: jax>=0.4.24
Requires-Dist: jaxlib>=0.4.24
Requires-Dist: jaxtyping>=0.2.25
Requires-Dist: kaggle>=1.6.6
Requires-Dist: loguru>=0.7.2
Requires-Dist: nox>=2023.4.22
Requires-Dist: polars>=0.20.9
Requires-Dist: pre-commit>=3.6.1
Requires-Dist: pytest>=8.0.1
Requires-Dist: tqdm>=4.66.2
Requires-Dist: typing-extensions>=4.5.0
Description-Content-Type: text/markdown

# jaxonloader

A dataloader, but for Jax

The idea of this package is to have a DataLoader similar to the PyTorch one. To ensure that you don't have to learn anything new to use this package, the same API is chosen here (PyTorch's API actually a very good).

Unfortunately, this also means that this package does _not_ follow the functional programming paradigm, because neither does the PyTorch DataLoader API. While in that regard this DataLoader is not _functional_ per se, it still allows for reproducability since you provide a random key to shuffle the data (if you want to).

At the moment, this package is not yet a 1:1 mapping from PyTorch's DataLoader, but one day, we will! \**holding up arm and clenching fist\**

## Installation

Install this package using pip like so:

```
pip install jaxonloader
```

## Usage

Pretty much exactly as you would use PyTorch's DataLoader. Create a dataset class by inheriting from the `jaxonloader` dataset and implement the `__len__` and `__getitem__` functions. Then simply pass that to the DataLoader class as argument.

On the other hand, you can also use some of the provided datasets, such as the MNIST dataset.

```python

import jax

from jaxonloader import get_mnist
from jaxonloader.dataloader import DataLoader
key = jax.random.PRNGKey(0)

train, test = get_mnist()

train_loader = DataLoader(
    train,
    batch_size=4,
    shuffle=False,
    drop_last=True,
    key=key,
)
x = next(iter(train_loader))
print(x[0].shape) # (4, 784)
print(x[1].shape) # (4,)


```
