Installation#

Important

Install PyTorch first. PyTorch is not installed automatically with complextorch — you must install the wheel matching your CUDA / CPU target from https://pytorch.org/get-started/locally/ before installing this package.

From PyPI#

pip install complextorch

PyPI project page →

From source#

For local development or to track main:

git clone https://github.com/josiahwsmith10/complextorch.git
cd complextorch
pip install -e .

Optional extras#

Extra

Adds

When to use it

complextorch[test]

pytest, pytest-cov, pytest-xdist, hypothesis

Running the test suite locally.

complextorch[docs]

Sphinx + PyData theme + MyST + autoapi + myst-nb + multiversion

Building these docs locally.

complextorch[datasets]

h5py

Future SAR / MRI dataset readers (PolSFDataset, MICCAI2023, …).

complextorch[datasets-alos]

rasterio

ALOS-2 CEOS-format reader (needs system-level GDAL).

Install combinations with the usual pip syntax, e.g.:

pip install -e .[test,docs]

Verifying the install#

import torch
import complextorch as ctorch

print(ctorch.__version__)

x = torch.randn(8, 5, 7, dtype=torch.cfloat)
y = ctorch.nn.Conv1d(5, 16, kernel_size=3)(x)
print(y.shape, y.dtype)   # torch.Size([8, 16, 5])  torch.complex64

If that runs without error, you’re set. Continue to the Getting Started notebook.