Skip to content

【创新应用】新增 QReupload:数据重上传变分量子学习模块(可训练 input scaling + Fourier/贫瘠高原诊断)#24

Open
freak-jaeuk wants to merge 2 commits into
OriginQ:developfrom
freak-jaeuk:feat/qreupload
Open

【创新应用】新增 QReupload:数据重上传变分量子学习模块(可训练 input scaling + Fourier/贫瘠高原诊断)#24
freak-jaeuk wants to merge 2 commits into
OriginQ:developfrom
freak-jaeuk:feat/qreupload

Conversation

@freak-jaeuk

Copy link
Copy Markdown

What

Adds pyqpanda_alg/QReupload/, the package's first supervised estimator whose
circuit parameters are trained against a task loss
(sklearn-style fit).
QSVM/QSVR fit only a classical SVM over a parameter-free quantum feature
map; QSVD/QAOA are variational but not supervised ML estimators.

  • QReuploadRegressor / QReuploadClassifier — data re-uploading models with
    a trainable input-scaling factor and an optional CNOT entangling ring,
    trained with exact adjoint gradients (vqcircuit.VQCircuit + ADJOINT_DIFF).
  • fourier_spectrum(model) — recovers which Fourier harmonics a fitted
    1-feature model learned (the model realises a truncated Fourier series; Schuld,
    Sweke & Meyer, PRA 103, 032430, 2021).
  • trainability_scan(qubit_range) — barren-plateau diagnostic,
    Var[∂⟨Z⟩/∂θ] vs qubit count.

Why

Gives pyqpanda-algorithm a trainable QML model (not just kernels), plus two
tools that make encoding expressivity and trainability inspectable before
scaling a circuit.

Validation

  • test/QAlgBase/Test_QReupload.py10 unit tests pass: behaviour (fit,
    band-limited spectrum, entanglement necessity on a non-separable cross-frequency
    target, classifier, barren-plateau decay, parameter count, multi-feature smoke)
    and estimator-contract checks (rejects wrong feature count / length-mismatched /
    non-finite input, get_params/set_params round-trip).
  • example/QAlgBase/testeg_qreupload.py — three demos: (A) 1-feature
    regression + learned Fourier-spectrum readout; (B) an entangle-vs-no-entangle
    ablation on y = 2sin(x0) + 1.5cos(x1) + sin(x0+x1) (the cross term makes
    entanglement load-bearing); (C) a barren-plateau scan. Each is shown next to
    a classical Fourier-ridge baseline — no over-claiming: the classical full-Fourier
    model appears only as an oracle handed the exact basis a priori.

Notes (verified on pyqpanda3 0.3.5)

  • Data is baked per-sample as a constant (Param(λ)·float(x)); a product of two
    placeholders (Param·Param) yields a zero adjoint gradient on pyqpanda3 0.3.5.
  • Input-scaling factors initialise near 1.0 (≈0 collapses the encoding).
  • The module needs only numpy + pyqpanda3; the example imports sklearn for
    the classical comparator (same as the existing QSVR/QKmeans examples).
  • fourier_spectrum is documented as an empirical DFT: the strict integer-degree
    bound holds for unit input scaling, since a trained scaling factor can move peaks
    off the integer grid.

The new subpackage is registered in pyqpanda_alg/__init__.py alongside the
existing QSVM/QSVD/… modules; the test follows this repo's test/pytest.ini
(Test_*.py under test/QAlgBase/) and Test(feature, content) case naming.

Add pyqpanda_alg/QReupload — the package's first supervised estimator whose
circuit parameters are trained against a task loss (sklearn-style fit), using
exact adjoint gradients (vqcircuit.VQCircuit + ADJOINT_DIFF).

- QReuploadRegressor / QReuploadClassifier: data re-uploading models with a
  trainable input-scaling factor and an optional CNOT entangling ring.
- fourier_spectrum: recover the learned Fourier harmonics of a 1-feature model.
- trainability_scan: barren-plateau diagnostic (Var[d<Z>/dtheta] vs qubit count).
- example/QAlgBase/testeg_qreupload.py: spectrum readout, entanglement ablation
  on a non-separable cross-frequency target, and a barren-plateau scan, each
  shown next to a classical Fourier-ridge baseline (no over-claiming).
- test/QAlgBase/Test_QReupload.py: 10 unit tests (behaviour + estimator contract).

Registers the subpackage in pyqpanda_alg/__init__.py, matching the existing
QSVM/QSVD/... convention.
- README.md: add a Chinese (中文) section alongside the English reference.
- Tutorials/source/QReupload.rst: narrative walkthrough (quick start, learned
  Fourier-spectrum readout, when entanglement matters, barren-plateau scan).
- Tutorials/source/index.rst: register the tutorial and the QReupload API
  reference in the toctree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant