Metadata-Version: 2.1
Name: torchstruct
Version: 0.1.5.post0
Summary: UNKNOWN
Home-page: https://github.com/iamhatesz/torchstruct
Author: Tomasz Wrona
Author-email: tomasz@wrona.me
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Version Control :: Git
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Python: >=3
Description-Content-Type: text/markdown
Requires-Dist: torch

# torchstruct

Wrap your multiple `torch.Tensor`s into single `TensorStruct`
and use it like you are using `torch.Tensor`.

## Installation

```bash
pip install torchstruct
```

## Testing

```bash
PYTHONPATH=. pytest
```

## Examples

```python
import torch
from torchstruct import TensorStruct

# Initialization
ts = TensorStruct.zeros({
    'obs': (2,),
    'rew': (1,),
    'done': (1,)
}, prefix_shape=(10,), dtype=torch.float32, device='cpu')

raw_data = {
    'obs': torch.randn((10, 2)),
    'rew': torch.randn((10, 1)),
    'done': torch.randn((10, 1))
}

# Assigning
ts[:] = raw_data

# Indexing
ts[2:4]
ts['rew']

# Calling PyTorch methods
ts.unsqueeze(dim=0)
ts.sum(dim=0)
```


