Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchstruct-0.1.6.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

torchstruct-0.1.6-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file torchstruct-0.1.6.tar.gz.

File metadata

  • Download URL: torchstruct-0.1.6.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

Hashes for torchstruct-0.1.6.tar.gz
Algorithm Hash digest
SHA256 aca3caaf4b05a399aaa6e69198e8d056caac6cfd5434e47b1b9b37b3d0e1ef68
MD5 00cfc1ee665432dc595b4c8f19a1ec75
BLAKE2b-256 09c8216291e49d68ed2b923f5c2de8d8a63ad39decdf30f418bc444920599280

See more details on using hashes here.

File details

Details for the file torchstruct-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: torchstruct-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.9 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

Hashes for torchstruct-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e1b1019be87ec2de0387b9909d496039dc5583e8f7f678a85d87658b73ed64ff
MD5 539b3a7e996edca0de2084ec14558ad9
BLAKE2b-256 91118cf4a900141fb491f972c397fab960c88bc3f3040ea09c80521ad1c2825f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page