Skip to main content

Synthetic complex-valued phase-coherence sample generator

Project description

PCC Sampler

pcc-sampler (Phase Coherence Complex - Sampler) generates synthetic complex-valued image samples where the label is defined by spatial phase coherence rather than amplitude cues.

The package is intentionally small: config in, deterministic complex samples out. It is meant to be imported by experiments that study complex-valued neural networks.

Install

The examples below use the uv command. If uv is installed but not on PATH, run the same commands as python -m uv ....

Install the project environment with uv:

uv sync

Run a quick import check:

uv run python -c "from pcc import load_default_config; print(load_default_config())"

From another local uv project, add this repo in editable mode:

uv add --editable C:\Users\meisa\Projects\pcc

Or add it from a Git URL after publishing the repo:

uv add "pcc-sampler @ git+https://github.com/<owner>/<repo>.git"

Python Usage

from pcc import PCCConfig, PCCDataset

cfg = PCCConfig(
    N=128,
    phase_smooth_sigma=2.0,
    incoh_highpass_sigma=16.0,
    incoh_scale=0.2,
    uniformize_phase_hist=True,
)

dataset = PCCDataset(size=10_000, cfg=cfg, seed=42)
z, amplitude, phase, y = dataset[0]

Returned values:

  • z: complex-valued sample, shape (N, N), dtype numpy.complex64
  • amplitude: amplitude field, shape (N, N), dtype numpy.float32
  • phase: phase field, shape (N, N), dtype numpy.float32
  • y: label scalar, where 0 is coherent and 1 is incoherent

YAML Config Usage

Create a YAML file:

N: 128
amp_radial_decay: 2.2
amp_smooth_sigma: 6.0
amp_range: [0.7, 1.4]

phase_smooth_sigma: 2.0
incoh_highpass_sigma: 16.0
incoh_scale: 0.2
global_phase: true
uniformize_phase_hist: true

translate_px: 16
rotate_deg: 30.0
noise_std: 0.1
renorm_amp: false

Load it directly:

from pcc import dataset_from_yaml

dataset = dataset_from_yaml("configs/pcc_phase.yaml", size=50_000, seed=7)

You can also load the built-in default:

from pcc import PCCDataset, load_default_config

cfg = load_default_config()
dataset = PCCDataset(size=1_000, cfg=cfg, seed=0)

Single Sample

from pcc import PCCConfig, make_deterministic_sample

cfg = PCCConfig()
z, amplitude, phase = make_deterministic_sample(cfg, y=0, seed=123, idx=0)

The same (seed, idx, y, config) combination produces the same sample.

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

pcc_sampler-0.2.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcc_sampler-0.2.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file pcc_sampler-0.2.0.tar.gz.

File metadata

  • Download URL: pcc_sampler-0.2.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pcc_sampler-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a34bd737fc857f41ef6d741c42b772a687885c0f89903cbffaa98b9ed6f42714
MD5 d68bf47cf27c3fda7e28bd4044e6d53b
BLAKE2b-256 b38afdc1a1c848370631cf5ad97c871811b67c27099df53eb53f28b973d2ef52

See more details on using hashes here.

File details

Details for the file pcc_sampler-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pcc_sampler-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pcc_sampler-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f078b47fa62d8b342c1e893dadcfc34d8f84c95391cee86a5c92dec5a7140f06
MD5 2aa3c831787759e77a1a2b96d06a3e1f
BLAKE2b-256 35e2fcd50ce570baadd55c0e3a5bf3a9365e52bbc682e356ba2448012d6f009c

See more details on using hashes here.

Supported by

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