No project description provided
Project description
torchstruct
Wrap your multiple torch.Tensors into single TensorStruct
and use it like you are using torch.Tensor.
Installation
pip install torchstruct
Testing
PYTHONPATH=. pytest
Examples
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)
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 torchstruct-0.1.5.post0.tar.gz.
File metadata
- Download URL: torchstruct-0.1.5.post0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
888e3c7b8112ebd3694770638bbfb4e9fe641303336749daa28a62a9c50d81d5
|
|
| MD5 |
9ec78b1d0a2ffc04b91ea5deb75c21e4
|
|
| BLAKE2b-256 |
f489c5406cefba4ceb659e33370fe2854e52a06efe3fdc24312ad09a4764334f
|
File details
Details for the file torchstruct-0.1.5.post0-py3-none-any.whl.
File metadata
- Download URL: torchstruct-0.1.5.post0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c134151dac90db31a92e91451da8e7fff3ee0c8162a5dd2cf316fac4ab3b661
|
|
| MD5 |
26afe1930a204aa6c5e7c1d3bfbbe499
|
|
| BLAKE2b-256 |
ecb9a1cd8f003c8c405e0791fb836cdb3309acce4b4819b9e8cf63342b16e32f
|