Skip to main content

neural-encoder

Python 3.12+ NeurIPS 2026 Run Tests

neural-encoder is a Python package for learning embeddings from repeated measurements and multiview data. It provides a linear encoder and an optional nonlinear refinement stage through a scikit-learn-style API.

The methods are based on Platonic Representations in the Human Brain: Unsupervised Recovery of Universal Geometry. Developed for fMRI, they apply more generally to repeated or multiview measurements with a common feature space.

Installation

pip install git+https://github.com/pablomm/neural-encoder.git

Usage

NeuralEncoder combines feature reliability weighting, PCA, distilled multiset canonical correlation analysis (MCCA), and nonlinear residual refinement. By default, the residual network receives the MCCA embedding, reproducing the paper architecture. It can instead receive PCA scores while still learning a correction in the MCCA embedding space.

Repeated measurements

X_train contains measurements as rows and features as columns. sample_ids identifies which rows are measurements of the same sample. Repetitions are assigned by their order of appearance within each sample.

from neural_encoder import NeuralEncoder

encoder = NeuralEncoder(
    n_components_pca=64,
    n_components_mcca=16,
    refiner_kwargs={
        "network_kwargs": {"hidden_dim": 128},
        "steps": 2000,
        "batch_size": 256,
    },
    random_state=42,
)
Z_train = encoder.fit_transform(
    X_train, sample_ids=sample_ids,
)
Z_test = encoder.transform(X_test)

Aligned views

When the measurements are already separated into aligned views, corresponding rows of X1, X2, and X3 represent the same sample.

from neural_encoder import NeuralEncoder

encoder = NeuralEncoder(
    n_components_pca=64,
    n_components_mcca=16,
    refinement_input_stage="pca",
    n_components_pca_refinement=128,
    refiner_kwargs={
        "network_kwargs": {"hidden_dim": 128},
        "steps": 2000,
        "batch_size": 256,
    },
    random_state=42,
)
encoder.fit_views([X1, X2, X3])

Z1, Z2, Z3 = (encoder.transform(X) for X in (X1, X2, X3))
Z_test = encoder.transform(X_test)

Preprocessing is applied separately. The complete fitted architecture can be exported to PyTorch:

model = encoder.to_pytorch()

To drive the residual branch from PCA scores, set refinement_input_stage="pca". An optional n_components_pca_refinement selects a separate PCA dimension; when omitted or equal to n_components_pca, both branches share one fitted PCA. Network, loss, and training settings can be configured through refiner_kwargs.

Citation

If you use this package in your research, please cite:

@misc{marcosmanchon2026platonic,
  title = {Platonic Representations in the Human Brain: Unsupervised Recovery of Universal Geometry},
  author = {Pablo Marcos-Manchón and Rishi Jha and Lluís Fuentemilla},
  year = {2026},
  eprint = {2605.20496},
  archivePrefix = {arXiv},
  primaryClass = {q-bio.NC},
  url = {https://arxiv.org/abs/2605.20496}
}

Metadata

Release files for neural-encoder 0.0.1

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

Source distribution (sdist)

Source distribution for neural-encoder 0.0.1
File Size Uploaded
neural_encoder-0.0.1.tar.gz 61.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for neural-encoder 0.0.1
File Interpreter ABI Platform
neural_encoder-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 119.8 kB

Release files / neural_encoder-0.0.1.tar.gz

Download URL neural_encoder-0.0.1.tar.gz
Size 61.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c5a57c2eb0c836f5dc46d8f47f234cd0c3df646e2f5bb92de276b136d4df1a7c
BLAKE2b-256 checksum
How to use checksums
c6137d6a22612e6ef0ad087f6812fa892338f197cda7b21e7fb999090261d69e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / neural_encoder-0.0.1-py3-none-any.whl

Download URL neural_encoder-0.0.1-py3-none-any.whl
Size 58.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
079902cfa6e8d53f804f8c667dcda35453941ff66b8287c9bae6ef4b956c49d4
BLAKE2b-256 checksum
How to use checksums
bf155d20c11271681125e0dd10b0b95b18ce18e5537b2e4308328472166878ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

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