torch-complex
A fugacious python class for PyTorch-ComplexTensor
What it is and what it does
torch_complex is a thin wrapper that simulates PyTorch's missing ComplexTensor type by pairing real and imaginary torch.Tensor objects. It implements basic arithmetic (addition, multiplication, division, exponentiation), matrix operations (batch matmul, batch inverse, conjugate), and functional operations (cat, stack, einsum) on complex values. The package also supports GPU operations (cuda/cpu) and autograd backpropagation.
The author explicitly describes this as a temporary workaround for PyTorch's lack of native complex tensor support at the Python level, intending to deprecate it once PyTorch adds the feature. All operations are implemented by composing real-valued PyTorch operations at the Python level, so performance is not optimized. It requires Python 3.6+ and PyTorch 1.0+.
Use it for:
- Prototyping signal processing or Fourier-domain neural networks when native PyTorch complex support is unavailable.
- Implementing complex-valued layers in deep learning models that require complex arithmetic.
- Performing batch matrix operations on complex-valued data (matmul, inverse, einsum).
- Training models with complex-valued activations or loss functions using autograd.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Python class wrapping real and imaginary PyTorch tensors to simulate complex tensor operations until native PyTorch support arrives.
No. The package is dormant and explicitly positioned as a temporary workaround. PyTorch has since added native ComplexTensor support, making this wrapper unnecessary for modern projects. Install only if you are locked into an old PyTorch version that lacks complex tensor support and cannot upgrade.
Install
torch-complex on PyPI
pip
pip install torch-complexuv
uv add torch-complexpoetry
poetry add torch-complexInstalling torch-complex
Before you install
Low install friction with only packaging and numpy as runtime dependencies. Package is dormant (777 days since last release) but marked Production/Stable; use only if you accept no active maintenance.
License in practice
Licensed under Apache Software License (permissive), imposing no significant restrictions on use or modification.
Quickstart
pip install torch_complex
from torch_complex.tensor import ComplexTensor
import numpy as np
real = np.random.randn(3, 10, 10)
imag = np.random.randn(3, 10, 10)
x = ComplexTensor(real, imag)
result = x + x
Requires PyTorch 1.0+ and Python 3.6+; performance is poor because all operations are implemented in Python rather than at the C++ level.
Verify before relying
- Whether PyTorch has since added native ComplexTensor support that would make this package obsolete.
- Performance characteristics compared to native PyTorch operations or alternative complex tensor libraries.
- Compatibility with recent PyTorch versions beyond those listed in classifiers.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — packaging, numpy |
| Maintenance | dormant — 777 days since the last release |
| First released | |
| Downloads | 413,667/month — #6,840 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: torch_complex-0.4.4-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
pytorch-forecastingPyTorch Forecasting provides neural network…
permissive · top 15,000 on PyPI
torch-geometricPyTorch Geometric is a library for building and…
permissive · top 5,000 on PyPI
torch-einops-utilsProvides utility functions for PyTorch and…
permissive · top 15,000 on PyPI
torchtypingAdds type annotations for PyTorch tensor shape,…
permissive · top 15,000 on PyPI
tensorlyTensorLy performs tensor decomposition, tensor…
permissive · top 15,000 on PyPI
tensordictTensorDict is a batched, nested dictionary…
permissive · top 5,000 on PyPI
pytorchcvProvides a collection of pretrained computer…
unclear · top 15,000 on PyPI
linear-operatorLinearOperator abstracts structured matrix…
permissive · top 5,000 on PyPI
e3nne3nn provides PyTorch-based operations for…
permissive · top 15,000 on PyPI