pytorch_complex
A temporal python class for PyTorch-ComplexTensor
What is this?
A Python class to perform as ComplexTensor in PyTorch: Nothing except for the following,
class ComplexTensor:
def __init__(self, ...):
self.real = torch.Tensor(...)
self.imag = torch.Tensor(...)
Why?
PyTorch is great DNN Python library, except that it doesn't support ComplexTensor in Python level.
https://github.com/pytorch/pytorch/issues/755
I'm looking forward to the completion, but I need ComplexTensor for now.
I created this cheap module for the temporal replacement of it. Thus, I'll throw away this project as soon as ComplexTensor is completely supported!
Requirements
Python>=3.6
PyTorch>=1.0
Install
pip install torch_complex
How to use
Basic mathematical operation
import numpy as np
from torch_complex.tensor import ComplexTensor
real = np.random.randn(3, 10, 10)
imag = np.random.randn(3, 10, 10)
x = ComplexTensor(real, imag)
x.numpy()
x + x
x * x
x - x
x / x
x ** 1.5
x @ x # Batch-matmul
x.conj()
x.inverse() # Batch-inverse
All are implemented with combinations of computation of RealTensor in python level, thus the speed is not good enough.
Functional
import torch_complex.functional as F
F.cat([x, x])
F.stack([x, x])
F.matmul(x, x) # Same as x @ x
F.einsum('bij,bjk,bkl->bil', [x, x, x])
For DNN
Almost all methods that torch.Tensor has are implemented.
x.cuda()
x.cpu()
(x + x).sum().backward()
Metadata
Release files for torch-complex 0.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torch_complex-0.4.4.tar.gz | 10.0 kB | Without provenance | Details for torch_complex-0.4.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torch_complex-0.4.4-py3-none-any.whl | Python 3 | none | any | Details for torch_complex-0.4.4-py3-none-any.whl |
Total release size: 19.1 kB
Release files / torch_complex-0.4.4.tar.gz
| Download URL | torch_complex-0.4.4.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4153fd6b24a0bad689e6f193bfbd00f38283b1890d808bef684ddc6d1f63fd3f
|
|
BLAKE2b-256 checksum How to use checksums |
bf2b17cb15a383cf2135330371e034d13b9043dc6d8bd07c871b5aa3064fbed1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.18
|
Release files / torch_complex-0.4.4-py3-none-any.whl
| Download URL | torch_complex-0.4.4-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ab4ecd4f3a16e3adb70a7f7cd2e769a9dfd07d7a8e27d04ff9c621ebbe34b13
|
|
BLAKE2b-256 checksum How to use checksums |
f4c59b4d756a7ada951e9b17dcc636f98ed1073c737ae809b150ef408afb6298
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.18
|
Security for torch-complex 0.4.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.