Skip to main content

PhasmaNet symbol

PhasmaNet

PhasmaNet (from Greek φάσμα, spectrum) is a compact neural architecture for structured tabular data. Learned input tokens are refined by an ordered cascade of attention-based Φ-Stages, each followed by a Φ-Refractor subspace-mixing module, and then revisited through gated top-down Φ-Feedback passes.

This package provides:

  • PhasmaNetRegressor and PhasmaNetClassifier: estimators with the familiar fit / predict interface, usable on any table of numerical features and compatible with scikit-learn tools (cross_val_score, Pipeline, clone).
  • phasmanet.gw.optimal_snr: a pretrained surrogate for the phase-averaged optimal signal-to-noise ratio of precessing, higher-mode binary black hole signals.
  • PhasmaNet, the PyTorch module itself, and MonotoneCalibrator, the rank-preserving PCHIP calibration used in the paper.

Installation

pip install phasmanet

PhasmaNet needs PyTorch. For GPU support, install the PyTorch build that matches your system first, following https://pytorch.org/get-started/locally/, and then install phasmanet. scikit-learn is optional (pip install "phasmanet[sklearn]").

Regression and classification on your own data

from phasmanet import PhasmaNetRegressor

reg = PhasmaNetRegressor(random_state=0)          # architecture of the paper by default
reg.fit(X_train, y_train)                         # early stopping on a 15% validation split
y_pred = reg.predict(X_test)
print(reg.score(X_test, y_test))                  # R^2

reg.save("model.pt")
reg = PhasmaNetRegressor.load("model.pt")
from phasmanet import PhasmaNetClassifier

clf = PhasmaNetClassifier(random_state=0).fit(X_train, y_train)
proba = clf.predict_proba(X_test)

Inputs are standardised internally, so raw features can be passed directly.

Hyperparameters

Every hyperparameter is a constructor argument; the defaults are the configuration used in the paper (about 0.73 M parameters).

Group Argument (default)
Architecture num_stages (3), num_feedback (2), num_tokens (8), hidden_dim (128), heads (4), num_refractor_subspaces (4), use_refractor (True), ffn_mult (4), activation ("gelu"; also "relu", "silu", "tanh", "elu", "leaky_relu"), dropout (0.1), attn_dropout (0.0)
Optimisation optimizer ("adamw", "adam", "sgd"), lr (1e-3), weight_decay (1e-4), momentum (0.9, SGD), batch_size (128), grad_clip (None)
Schedule and stopping max_epochs (150), patience (20), min_delta (1e-6), scheduler ("plateau", "cosine", "none"), lr_patience (5), lr_factor (0.5), validation_fraction (0.15)
Regression only loss ("mse" or "huber"), huber_delta (1.0), weighting ("none", "by_hist", "inverse_freq"), hist_bins (20), wmin (0.2), wmax (5.0), calibrate (False), calibration_bins (60), calibration_min_bin (20)
Classification only class_weight (None or "balanced")
Other device ("auto"), random_state (None), verbose (0)

fit also accepts sample_weight and validation_data=(X_val, y_val). After fitting, history_ holds the training and validation loss and the learning rate per epoch. Because the estimators follow the scikit-learn conventions, hyperparameters can be searched with GridSearchCV, RandomizedSearchCV or Optuna.

The defaults were chosen for smooth, low-noise targets such as simulator outputs; for other data, tune at least hidden_dim, num_tokens, lr and max_epochs.

Optimal SNR of binary black hole signals

import numpy as np
from phasmanet.gw import optimal_snr, chirp_mass, mass_ratio, spins_from_spherical

m1, m2 = np.array([36.0, 10.0]), np.array([29.0, 8.0])     # detector-frame masses, Msun
rho = optimal_snr(
    mchirp=chirp_mass(m1, m2),
    q=mass_ratio(m1, m2),                                    # m_heavy / m_light >= 1
    cos_inclination=np.array([0.3, -0.8]),
    spin1=spins_from_spherical([0.5, 0.1], [0.4, 2.0], [1.0, 3.0]),
    spin2=spins_from_spherical([0.2, 0.0], [1.0, 0.0], [0.0, 0.0]),
    f_plus=np.array([0.4, -0.2]),
    f_cross=np.array([0.1, 0.6]),
    distance=np.array([410.0, 800.0]),                      # luminosity distance, Mpc
)

Configuration of the pretrained model: single LIGO-Hanford detector, Advanced LIGO zero-detuned high-power PSD, IMRPhenomXPHM waveforms, f_low = 10 Hz, SNR averaged over the coalescence phase. Training covered component masses 3 to 170 Msun (detector frame), spin magnitudes up to 0.99 and SNR below 200 at 1000 Mpc. The optimal SNR scales exactly as 1/d_L, which optimal_snr applies for the given distance. Inputs outside the training domain produce a warning. Throughput depends strongly on the hardware: a GPU is recommended for catalogue-scale evaluations (millions of injections). Antenna patterns f_plus, f_cross can be computed with PyCBC, Bilby or LALSuite for any sky position, polarisation and time.

Reproducing the paper

The training scripts, baselines and diagnostics used in the paper are in the repository: https://github.com/giannis00/PhasmaNet-SNR

Citation

If you use PhasmaNet, please cite the paper (see CITATION.cff):

I. Tsioulis, A. Tefas, N. Stergioulas, ΦasmaNet: A Staged Spectral Token-Refinement Architecture for Fast Gravitational-Wave Signal-to-Noise Ratio Prediction, arXiv (2026).

License

MIT. See LICENSE.

Metadata

Release files for phasmanet 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for phasmanet 0.1.0
File Size Uploaded Provenance Actions
phasmanet-0.1.0.tar.gz 2.8 MB Without provenance Details for phasmanet-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for phasmanet 0.1.0
File Interpreter ABI Platform Actions
phasmanet-0.1.0-py3-none-any.whl Python 3 none any Details for phasmanet-0.1.0-py3-none-any.whl

Total release size: 5.5 MB

Release files / phasmanet-0.1.0.tar.gz

Download URL phasmanet-0.1.0.tar.gz
Size 2.8 MB
Tags Source
SHA-256 checksum
How to use checksums
2403670b9d35eae2f48882e6aa4d93c4df85c20a2a731bd8a13b961c202fd599
BLAKE2b-256 checksum
How to use checksums
db5913302fb98084b98509d2c9dd86d286bd7b10bb3b5e23777333f8973210f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.0

Release files / phasmanet-0.1.0-py3-none-any.whl

Download URL phasmanet-0.1.0-py3-none-any.whl
Size 2.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0d779457dd3ae8125dd8468a833ef1bdaab8446281383926b74e410c51cdb210
BLAKE2b-256 checksum
How to use checksums
ee57e8dec333d6410391fcd4f2c3b4a8ecd829373e43b1fecb731bf89203fce9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.0

Security for phasmanet 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page