squlearn 0.8.2__tar.gz → 0.8.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {squlearn-0.8.2 → squlearn-0.8.3}/PKG-INFO +1 -1
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/modules/classes.rst +1 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/__init__.py +1 -1
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/encoding_circuit_base.py +167 -22
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/transpiled_encoding_circuit.py +2 -2
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/lowlevel_kernel/fidelity_kernel.py +101 -53
- squlearn-0.8.3/src/squlearn/kernel/lowlevel_kernel/fidelity_kernel_expectation_value.py +523 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/lowlevel_kernel/kernel_matrix_base.py +21 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/lowlevel_kernel/projected_quantum_kernel.py +1 -1
- squlearn-0.8.3/tests/kernel/matrix/test_fidelity_quantum_kernel.py +187 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/CODE_OF_CONDUCT.md +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/CONTRIBUTING.md +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/workflows/doc_checks.yml +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/workflows/format.yml +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/workflows/publish.yml +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/workflows/publish_docs.yml +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.github/workflows/tests.yaml +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/.gitignore +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/CITATION.cff +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/LICENSE.txt +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/README.md +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/Makefile +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/README.md +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/css/custom.css +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/favicon.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/logo.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/qkm/QKM_scheme_pic.jpg +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/qnn/qnn.svg +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/qrc/QRC_user_guide.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/qrc/qrc_classification_transparent.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/qrc/qrc_regression_transparent.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/schematic.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_static/util/executor.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_templates/class.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_templates/class_with_call.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/_templates/function.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/conf.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/examples/example_kernel_digit_classification.nblink +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/examples/example_kernel_grid_search.nblink +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/examples/example_qnn_backend_mitigation.nblink +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/examples/example_qnn_ode_solver.nblink +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/examples/example_quantum_bayesian_optimization.nblink +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/examples/examples_index.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/index.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/install/install.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/make.bat +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/qiskit_settings.conf +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/spelling_wordlist.txt +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/user_guide/encoding_circuits.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/user_guide/executor.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/user_guide/kernel_methods.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/user_guide/observables.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/user_guide/quantum_neural_networks.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/user_guide/quantum_reservoir_computing.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/docs/user_guide/user_guide_index.rst +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/encoding_circuits/layered_encoding_circuit.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/encoding_circuits/pruning_example.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/encoding_circuits/various_encoding_circuit.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/executor/example_executor_qiskit.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/integration/mlflow.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/kernel/example_fidelity_kernel.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/kernel/example_projected_kernel.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/kernel/example_regularization_mitigation.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/kernel/qgpc_workflow.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/kernel/qgpr_optimization_workflow.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/kernel/qgpr_workflow.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qnn/classification_example.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qnn/example_adam.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qnn/example_minibatch.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qnn/example_qcnn_encoding_circuit.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qnn/ode_example.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qnn/regression_example.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qnn/regression_with_variance.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qrc/qrc_classification.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/qrc/qrc_regression.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/images/QNN_ode_workflow.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/images/encoding_circuit.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/images/pipeline.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/images/projected_quantum_kernel.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/images/quantum_bo.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/kernel_digit_classification.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/kernel_grid_search.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/kernel_regression.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/qnn_backend_mitigation.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/qnn_ode_solver.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/examples/tutorials/quantum_bayesian_optimization.ipynb +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/install_lowest_dependencies.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/output.png +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/pyproject.toml +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/chebyshev_pqc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/chebyshev_rx.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/chebyshev_tower.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/highdim_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/hubregtsen_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/kyriienko_nonlinear_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/multi_control_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/param_z_feature_map.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/qcnn_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/qiskit_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/random_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/random_layered_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/circuit_library/yz_cx_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/encoding_circuit_derivatives.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/layered_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/pruned_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/loss/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/loss/kernel_loss_base.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/loss/negative_log_likelihood.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/loss/target_alignment.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/lowlevel_kernel/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/lowlevel_kernel/fidelity_kernel_pennylane.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/lowlevel_kernel/kernel_optimizer.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/lowlevel_kernel/kernel_util.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/lowlevel_kernel/regularization.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/qgpc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/qgpr.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/qkrr.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/qsvc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/kernel/qsvr.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_base.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_derivatives.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_implemented/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_implemented/custom_observable.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_implemented/ising_hamiltonian.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_implemented/single_pauli.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_implemented/single_probability.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_implemented/summed_paulis.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/observables/observable_implemented/summed_probabilities.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/optimizers/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/optimizers/adam.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/optimizers/approximated_gradients.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/optimizers/optimizer_base.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/optimizers/optimizers_wrapper.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/optimizers/sglbo.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/base_qnn.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/loss/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/loss/ode_loss.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/loss/parameter_regularization_loss.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/loss/qnn_loss_base.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/loss/squared_loss.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/loss/variance_loss.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/lowlevel_qnn/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/lowlevel_qnn/lowlevel_qnn.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/lowlevel_qnn/lowlevel_qnn_base.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/lowlevel_qnn/lowlevel_qnn_pennylane.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/lowlevel_qnn/lowlevel_qnn_qiskit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/qnnc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/qnnr.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/util/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/util/barren_plateau_analysis.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qnn/util/training.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qrc/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qrc/base_qrc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qrc/qrc_classifier.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/qrc/qrc_regressor.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/data_preprocessing.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/decompose_to_std.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/execution/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/execution/automatic_backend_selection.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/execution/hqaa/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/execution/hqaa/heuristic.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/execution/hqaa/parser.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/execution/parallel_estimator.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/execution/parallel_sampler.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/executor.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/optree/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/optree/optree.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/optree/optree_derivative.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/optree/optree_evaluate.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/pennylane/__init__.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/pennylane/pennylane_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/pennylane/pennylane_gates.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/util/qfi.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/encoding_circuit/test_layered_encoding_circuit.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/encoding_circuit/test_random_encoding_circuits.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/kernel/matrix/test_kernel_optimizer.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/kernel/matrix/test_projected_quantum_kernel.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/kernel/ml/test_qgpc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/kernel/ml/test_qgpr.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/kernel/ml/test_qkrr.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/kernel/ml/test_qsvc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/kernel/ml/test_qsvr.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/optimizers/test_sglbo.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/qnn/test_base_qnn.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/qnn/test_qnnc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/qnn/test_qnnr.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/qnn/test_training.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/qrc/test_base_qrc.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/qrc/test_qrc_classifier.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/qrc/test_qrc_regressor.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/util/execution/test_automatic_backend_selection.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/util/execution/test_parallel_primitives.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/util/optree/test_optree_derivative.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/util/optree/test_optree_evaluate.py +0 -0
- {squlearn-0.8.2 → squlearn-0.8.3}/tests/util/test_executor.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: squlearn
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.3
|
|
4
4
|
Summary: A library for quantum machine learning following the scikit-learn standard.
|
|
5
5
|
Keywords: quantum,machine learning,qml
|
|
6
6
|
Author-email: David Kreplin <david.kreplin@ipa.fraunhofer.de>, Moritz Willmann <moritz.willmann@ipa.fraunhofer.de>, Jan Schnabel <jan.schnabel@ipa.fraunhofer.de>, Frederic Rapp <frederic.rapp@ipa.fraunhofer.de>, Manuel Hagelüken <manuel.hagelueken@ipa.fraunhofer.de>, Marco Roth <marco.roth@ipa.fraunhofer.de>
|
|
@@ -73,7 +73,9 @@ class EncodingCircuitBase:
|
|
|
73
73
|
parameters: Union[ParameterVector, np.ndarray],
|
|
74
74
|
) -> QuantumCircuit:
|
|
75
75
|
"""
|
|
76
|
-
Return the circuit encoding circuit
|
|
76
|
+
Return the circuit encoding circuit
|
|
77
|
+
|
|
78
|
+
Has to be overwritten, otherwise a NotImplementedError is thrown
|
|
77
79
|
|
|
78
80
|
Args:
|
|
79
81
|
features Union[ParameterVector,np.ndarray]: Input vector of the features
|
|
@@ -154,13 +156,78 @@ class EncodingCircuitBase:
|
|
|
154
156
|
|
|
155
157
|
return self
|
|
156
158
|
|
|
159
|
+
def inverse(self):
|
|
160
|
+
"""
|
|
161
|
+
Returns the inverse of the encoding circuit.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
The inverse of the encoding circuit
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
class InvertedEncodingCircuit(EncodingCircuitBase):
|
|
168
|
+
def __init__(self, encoding_circuit: EncodingCircuitBase):
|
|
169
|
+
super().__init__(encoding_circuit.num_qubits, encoding_circuit.num_features)
|
|
170
|
+
self._encoding_circuit = encoding_circuit
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def num_parameters(self) -> int:
|
|
174
|
+
"""Returns the number of trainable parameters of the encoding circuit."""
|
|
175
|
+
return self._encoding_circuit.num_parameters
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def parameter_bounds(self) -> np.ndarray:
|
|
179
|
+
"""Returns the bounds of the trainable parameters of the encoding circuit."""
|
|
180
|
+
return self._encoding_circuit.parameter_bounds
|
|
181
|
+
|
|
182
|
+
@property
|
|
183
|
+
def feature_bounds(self) -> np.ndarray:
|
|
184
|
+
"""Returns the bounds of the features of the encoding circuit."""
|
|
185
|
+
return self._encoding_circuit.feature_bounds
|
|
186
|
+
|
|
187
|
+
def generate_initial_parameters(self, seed: Union[int, None] = None) -> np.ndarray:
|
|
188
|
+
"""
|
|
189
|
+
Generates random parameters for the encoding circuit
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
seed (Union[int,None]): Seed for the random number generator
|
|
193
|
+
|
|
194
|
+
Return:
|
|
195
|
+
Returns the randomly generated parameters
|
|
196
|
+
"""
|
|
197
|
+
return self._encoding_circuit.generate_initial_parameters(seed)
|
|
198
|
+
|
|
199
|
+
def get_circuit(
|
|
200
|
+
self,
|
|
201
|
+
features: Union[ParameterVector, np.ndarray],
|
|
202
|
+
parameters: Union[ParameterVector, np.ndarray],
|
|
203
|
+
) -> QuantumCircuit:
|
|
204
|
+
"""
|
|
205
|
+
Returns the inverse circuit of the encoding circuit
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
features Union[ParameterVector,np.ndarray]: Input vector of the features
|
|
209
|
+
from which the gate inputs are obtained
|
|
210
|
+
param_vec Union[ParameterVector,np.ndarray]: Input vector of the parameters
|
|
211
|
+
from which the gate inputs are obtained
|
|
212
|
+
|
|
213
|
+
Return:
|
|
214
|
+
Returns the inverse circuit of the encoding circuit in qiskit QuantumCircuit
|
|
215
|
+
format
|
|
216
|
+
"""
|
|
217
|
+
circ = self._encoding_circuit.get_circuit(features, parameters)
|
|
218
|
+
return circ.inverse()
|
|
219
|
+
|
|
220
|
+
return InvertedEncodingCircuit(self)
|
|
221
|
+
|
|
157
222
|
def __mul__(self, x):
|
|
158
223
|
return self.__add__(x)
|
|
159
224
|
|
|
160
225
|
def __add__(self, x):
|
|
226
|
+
return self.compose(x, concatenate_features=False, concatenate_parameters=True)
|
|
227
|
+
|
|
228
|
+
def compose(self, x, concatenate_features=True, concatenate_parameters=False):
|
|
161
229
|
"""
|
|
162
|
-
|
|
163
|
-
encoding circuits returns the composition of both encoding circuits.
|
|
230
|
+
Composition of encoding circuits with options for handling features and parameters
|
|
164
231
|
|
|
165
232
|
Number of qubits and features have to be equal in both encoding circuits!
|
|
166
233
|
The special function and properties of the both encoding circuits are lost
|
|
@@ -182,7 +249,8 @@ class EncodingCircuitBase:
|
|
|
182
249
|
Special class for composed encoding circuits.
|
|
183
250
|
|
|
184
251
|
Args:
|
|
185
|
-
num_qubits: num qubits for both encoding circuits
|
|
252
|
+
num_qubits (int): num qubits for both encoding circuits
|
|
253
|
+
(necessary for scikit-learn interface)
|
|
186
254
|
ec1 (EncodingCircuitBase): right / first encoding circuit
|
|
187
255
|
ec2 (EncodingCircuitBase): left / second encoding circuit
|
|
188
256
|
"""
|
|
@@ -226,7 +294,18 @@ class EncodingCircuitBase:
|
|
|
226
294
|
|
|
227
295
|
Is equal to the sum of both trainable parameters.
|
|
228
296
|
"""
|
|
229
|
-
|
|
297
|
+
if concatenate_parameters:
|
|
298
|
+
return self.ec1.num_parameters + self.ec2.num_parameters
|
|
299
|
+
else:
|
|
300
|
+
return max(self.ec1.num_parameters, self.ec2.num_parameters)
|
|
301
|
+
|
|
302
|
+
@property
|
|
303
|
+
def num_features(self) -> int:
|
|
304
|
+
"""The dimension of the features in the encoding circuit."""
|
|
305
|
+
if concatenate_features:
|
|
306
|
+
return self.ec1.num_features + self.ec2.num_features
|
|
307
|
+
else:
|
|
308
|
+
return max(self.ec1.num_features, self.ec2.num_features)
|
|
230
309
|
|
|
231
310
|
@property
|
|
232
311
|
def parameter_bounds(self) -> np.ndarray:
|
|
@@ -234,9 +313,47 @@ class EncodingCircuitBase:
|
|
|
234
313
|
|
|
235
314
|
Is equal to the sum of both bounds.
|
|
236
315
|
"""
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
316
|
+
if concatenate_parameters:
|
|
317
|
+
return np.concatenate(
|
|
318
|
+
(self.ec1.parameter_bounds, self.ec2.parameter_bounds), axis=0
|
|
319
|
+
)
|
|
320
|
+
else:
|
|
321
|
+
# We compare self.ec1.parameter_bounds and self.ec2.parameter_bounds,
|
|
322
|
+
# we return a new array,
|
|
323
|
+
# with the shape of the largest array, and the minimum values of the two arrays
|
|
324
|
+
# for the first column (lower bound),
|
|
325
|
+
# and the maximum values of the two arrays for the second column (upper bound)
|
|
326
|
+
|
|
327
|
+
# Extend parameter bounds to the shape of the largest array with np.pad
|
|
328
|
+
parameter_bounds1_extended = np.pad(
|
|
329
|
+
self.ec1.parameter_bounds,
|
|
330
|
+
((0, self.num_parameters - self.ec1.num_parameters), (0, 0)),
|
|
331
|
+
constant_values=np.nan,
|
|
332
|
+
)
|
|
333
|
+
parameter_bounds2_extended = np.pad(
|
|
334
|
+
self.ec2.parameter_bounds,
|
|
335
|
+
((0, self.num_parameters - self.ec2.num_parameters), (0, 0)),
|
|
336
|
+
constant_values=np.nan,
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
# Compute the minimum lower bound values for the first column and maximum upper
|
|
340
|
+
# bounds for the second column
|
|
341
|
+
parameter_bounds3_first_col = np.nanmin(
|
|
342
|
+
np.array(
|
|
343
|
+
[parameter_bounds1_extended[:, 0], parameter_bounds2_extended[:, 0]]
|
|
344
|
+
),
|
|
345
|
+
axis=0,
|
|
346
|
+
)
|
|
347
|
+
parameter_bounds3_second_col = np.nanmax(
|
|
348
|
+
np.array(
|
|
349
|
+
[parameter_bounds1_extended[:, 1], parameter_bounds2_extended[:, 1]]
|
|
350
|
+
),
|
|
351
|
+
axis=0,
|
|
352
|
+
)
|
|
353
|
+
# Stack the results into the final array
|
|
354
|
+
return np.column_stack(
|
|
355
|
+
(parameter_bounds3_first_col, parameter_bounds3_second_col)
|
|
356
|
+
)
|
|
240
357
|
|
|
241
358
|
@property
|
|
242
359
|
def feature_bounds(self) -> np.ndarray:
|
|
@@ -274,13 +391,20 @@ class EncodingCircuitBase:
|
|
|
274
391
|
Returns the randomly generated parameters
|
|
275
392
|
"""
|
|
276
393
|
|
|
277
|
-
|
|
278
|
-
(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
394
|
+
if concatenate_parameters:
|
|
395
|
+
return np.concatenate(
|
|
396
|
+
(
|
|
397
|
+
self.ec1.generate_initial_parameters(seed),
|
|
398
|
+
self.ec2.generate_initial_parameters(seed),
|
|
399
|
+
),
|
|
400
|
+
axis=0,
|
|
401
|
+
)
|
|
402
|
+
else:
|
|
403
|
+
if self.num_parameters == 0:
|
|
404
|
+
return np.array([])
|
|
405
|
+
r = np.random.RandomState(seed)
|
|
406
|
+
bounds = self.parameter_bounds
|
|
407
|
+
return r.uniform(low=bounds[:, 0], high=bounds[:, 1])
|
|
284
408
|
|
|
285
409
|
def get_params(self, deep: bool = True) -> dict:
|
|
286
410
|
"""
|
|
@@ -291,7 +415,7 @@ class EncodingCircuitBase:
|
|
|
291
415
|
|
|
292
416
|
Args:
|
|
293
417
|
deep (bool): If True, also the parameters for
|
|
294
|
-
|
|
418
|
+
contained objects are returned (default=True).
|
|
295
419
|
|
|
296
420
|
Return:
|
|
297
421
|
Dictionary with hyper-parameters and values.
|
|
@@ -357,14 +481,35 @@ class EncodingCircuitBase:
|
|
|
357
481
|
from which the gate inputs are obtained
|
|
358
482
|
|
|
359
483
|
Return:
|
|
360
|
-
Returns the circuit of the composed encoding circuits in qiskit QuantumCircuit
|
|
484
|
+
Returns the circuit of the composed encoding circuits in qiskit QuantumCircuit
|
|
485
|
+
format
|
|
361
486
|
"""
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
487
|
+
if concatenate_features:
|
|
488
|
+
features_c1, features_c2 = (
|
|
489
|
+
features[: self.ec1.num_features],
|
|
490
|
+
features[self.ec1.num_features :],
|
|
491
|
+
)
|
|
492
|
+
else:
|
|
493
|
+
features_c1, features_c2 = (
|
|
494
|
+
features[: self.ec1.num_features],
|
|
495
|
+
features[: self.ec2.num_features],
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
if concatenate_parameters:
|
|
499
|
+
parameters_c1, parameters_c2 = (
|
|
500
|
+
parameters[: self.ec1.num_parameters],
|
|
501
|
+
parameters[self.ec1.num_parameters :],
|
|
502
|
+
)
|
|
503
|
+
else:
|
|
504
|
+
parameters_c1, parameters_c2 = (
|
|
505
|
+
parameters[: self.ec1.num_parameters],
|
|
506
|
+
parameters[: self.ec1.num_parameters],
|
|
507
|
+
)
|
|
508
|
+
|
|
509
|
+
circ1 = self.ec1.get_circuit(features_c1, parameters_c1)
|
|
366
510
|
circ2 = self.ec2.get_circuit(
|
|
367
|
-
|
|
511
|
+
features_c2,
|
|
512
|
+
parameters_c2, # Only line that changes, to include the new features
|
|
368
513
|
)
|
|
369
514
|
|
|
370
515
|
return circ1.compose(circ2, range(self.ec1.num_qubits))
|
{squlearn-0.8.2 → squlearn-0.8.3}/src/squlearn/encoding_circuit/transpiled_encoding_circuit.py
RENAMED
|
@@ -49,8 +49,8 @@ class TranspiledEncodingCircuit(EncodingCircuitBase):
|
|
|
49
49
|
self._backend = backend
|
|
50
50
|
self._transpile_func = transpile_func
|
|
51
51
|
|
|
52
|
-
self._x = ParameterVector("
|
|
53
|
-
self._p = ParameterVector("
|
|
52
|
+
self._x = ParameterVector("x_", self._encoding_circuit.num_features)
|
|
53
|
+
self._p = ParameterVector("p_", self._encoding_circuit.num_parameters)
|
|
54
54
|
|
|
55
55
|
self._circuit = decompose_to_std(self._encoding_circuit.get_circuit(self._x, self._p))
|
|
56
56
|
|
|
@@ -18,10 +18,11 @@ from ...util.executor import Executor, BaseSamplerV2
|
|
|
18
18
|
from ...util.data_preprocessing import convert_to_float64
|
|
19
19
|
|
|
20
20
|
from .fidelity_kernel_pennylane import FidelityKernelPennyLane
|
|
21
|
+
from .fidelity_kernel_expectation_value import FidelityKernelExpectationValue
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
class FidelityKernel(KernelMatrixBase):
|
|
24
|
-
"""
|
|
25
|
+
r"""
|
|
25
26
|
Fidelity Quantum Kernel.
|
|
26
27
|
|
|
27
28
|
The Fidelity Quantum Kernel is a based on the overlap of the quantum states.
|
|
@@ -30,7 +31,7 @@ class FidelityKernel(KernelMatrixBase):
|
|
|
30
31
|
|
|
31
32
|
.. math::
|
|
32
33
|
|
|
33
|
-
K(x,y) =
|
|
34
|
+
K(x,y) = |\langle \phi(x) | \phi(y) \rangle|^2
|
|
34
35
|
|
|
35
36
|
This class wraps to the respective Quantum Kernel implementations from `Qiskit Machine Learning
|
|
36
37
|
<https://qiskit.org/ecosystem/machine-learning/apidocs/qiskit_machine_learning.kernels.html>`_.
|
|
@@ -55,6 +56,12 @@ class FidelityKernel(KernelMatrixBase):
|
|
|
55
56
|
Option for choosing different regularization techniques (``"thresholding"`` or
|
|
56
57
|
``"tikhonov"``) after Ref. [4] for the training kernel matrix, prior to solving the
|
|
57
58
|
linear system in the ``fit()``-procedure.
|
|
59
|
+
use_expectation (bool, default=False):
|
|
60
|
+
Option for using the expectation value of a QNN circuit that computes the fidelity
|
|
61
|
+
as the expectation value of the observable
|
|
62
|
+
:math:`P_0 = |0\rangle\langle0|^{\otimes n}`.
|
|
63
|
+
This is not very efficient in simulation, but allows the computation of
|
|
64
|
+
derivatives of the kernel.
|
|
58
65
|
|
|
59
66
|
References:
|
|
60
67
|
[1]: `Havlicek et al., Supervised learning with quantum-enhanced feature spaces,
|
|
@@ -86,6 +93,8 @@ class FidelityKernel(KernelMatrixBase):
|
|
|
86
93
|
initial_parameters: Union[np.ndarray, None] = None,
|
|
87
94
|
parameter_seed: Union[int, None] = 0,
|
|
88
95
|
regularization: Union[str, None] = None,
|
|
96
|
+
use_expectation: bool = False,
|
|
97
|
+
caching: bool = False,
|
|
89
98
|
) -> None:
|
|
90
99
|
super().__init__(
|
|
91
100
|
encoding_circuit, executor, initial_parameters, parameter_seed, regularization
|
|
@@ -94,72 +103,82 @@ class FidelityKernel(KernelMatrixBase):
|
|
|
94
103
|
self._quantum_kernel = None
|
|
95
104
|
self._evaluate_duplicates = evaluate_duplicates
|
|
96
105
|
self._mit_depol_noise = mit_depol_noise
|
|
106
|
+
self._use_expectation = use_expectation
|
|
97
107
|
|
|
98
108
|
if self.num_parameters > 0:
|
|
99
109
|
self._parameter_vector = ParameterVector("p", self.num_parameters)
|
|
100
110
|
else:
|
|
101
111
|
self._parameter_vector = None
|
|
102
112
|
|
|
103
|
-
if self.
|
|
104
|
-
|
|
105
|
-
self._quantum_kernel = FidelityKernelPennyLane(
|
|
113
|
+
if self._use_expectation:
|
|
114
|
+
self._quantum_kernel = FidelityKernelExpectationValue(
|
|
106
115
|
encoding_circuit=self._encoding_circuit,
|
|
107
116
|
executor=self._executor,
|
|
108
117
|
evaluate_duplicates=self._evaluate_duplicates,
|
|
118
|
+
caching=caching,
|
|
109
119
|
)
|
|
110
120
|
|
|
111
|
-
|
|
121
|
+
else:
|
|
122
|
+
if self._executor.quantum_framework == "pennylane":
|
|
112
123
|
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
self._quantum_kernel = FidelityKernelPennyLane(
|
|
125
|
+
encoding_circuit=self._encoding_circuit,
|
|
126
|
+
executor=self._executor,
|
|
127
|
+
evaluate_duplicates=self._evaluate_duplicates,
|
|
128
|
+
)
|
|
115
129
|
|
|
116
|
-
self.
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
elif self._executor.quantum_framework == "qiskit":
|
|
131
|
+
|
|
132
|
+
# Underscore necessary to avoid name conflicts with the Qiskit quantum kernel
|
|
133
|
+
self._feature_vector = ParameterVector("x_", self.num_features)
|
|
119
134
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if self.
|
|
126
|
-
self.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
self._enc_circ = self._encoding_circuit.get_circuit(
|
|
136
|
+
self._feature_vector, self._parameter_vector
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# Automatic select backend if not chosen
|
|
140
|
+
if not self._executor.backend_chosen:
|
|
141
|
+
self._enc_circ, _ = self._executor.select_backend(self._enc_circ)
|
|
142
|
+
|
|
143
|
+
if self._executor.is_statevector:
|
|
144
|
+
if self._parameter_vector is None:
|
|
145
|
+
self._quantum_kernel = FidelityStatevectorKernel(
|
|
146
|
+
feature_map=self._enc_circ,
|
|
147
|
+
shots=self._executor.get_shots(),
|
|
148
|
+
enforce_psd=False,
|
|
149
|
+
)
|
|
150
|
+
else:
|
|
151
|
+
self._quantum_kernel = TrainableFidelityStatevectorKernel(
|
|
152
|
+
feature_map=self._enc_circ,
|
|
153
|
+
training_parameters=self._parameter_vector,
|
|
154
|
+
shots=self._executor.get_shots(),
|
|
155
|
+
enforce_psd=False,
|
|
156
|
+
)
|
|
131
157
|
else:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
158
|
+
sampler = self._executor.get_sampler()
|
|
159
|
+
if isinstance(sampler, BaseSamplerV2):
|
|
160
|
+
raise ValueError(
|
|
161
|
+
"Incompatible Qiskit version for Fidelity-Kernel calculation with Qiskit "
|
|
162
|
+
"Algorithms. Please downgrade to Qiskit 1.0 or consider using PennyLane."
|
|
163
|
+
)
|
|
164
|
+
fidelity = ComputeUncompute(sampler=sampler)
|
|
165
|
+
if self._parameter_vector is None:
|
|
166
|
+
self._quantum_kernel = FidelityQuantumKernel(
|
|
167
|
+
feature_map=self._enc_circ,
|
|
168
|
+
fidelity=fidelity,
|
|
169
|
+
evaluate_duplicates=self._evaluate_duplicates,
|
|
170
|
+
enforce_psd=False,
|
|
171
|
+
)
|
|
172
|
+
else:
|
|
173
|
+
self._quantum_kernel = TrainableFidelityQuantumKernel(
|
|
174
|
+
feature_map=self._enc_circ,
|
|
175
|
+
fidelity=fidelity,
|
|
176
|
+
training_parameters=self._parameter_vector,
|
|
177
|
+
evaluate_duplicates=self._evaluate_duplicates,
|
|
178
|
+
enforce_psd=False,
|
|
179
|
+
)
|
|
138
180
|
else:
|
|
139
|
-
|
|
140
|
-
if isinstance(sampler, BaseSamplerV2):
|
|
141
|
-
raise ValueError(
|
|
142
|
-
"Incompatible Qiskit version for Fidelity-Kernel calculation with Qiskit "
|
|
143
|
-
"Algorithms. Please downgrade to Qiskit 1.0 or consider using PennyLane."
|
|
144
|
-
)
|
|
145
|
-
fidelity = ComputeUncompute(sampler=sampler)
|
|
146
|
-
if self._parameter_vector is None:
|
|
147
|
-
self._quantum_kernel = FidelityQuantumKernel(
|
|
148
|
-
feature_map=self._enc_circ,
|
|
149
|
-
fidelity=fidelity,
|
|
150
|
-
evaluate_duplicates=self._evaluate_duplicates,
|
|
151
|
-
enforce_psd=False,
|
|
152
|
-
)
|
|
153
|
-
else:
|
|
154
|
-
self._quantum_kernel = TrainableFidelityQuantumKernel(
|
|
155
|
-
feature_map=self._enc_circ,
|
|
156
|
-
fidelity=fidelity,
|
|
157
|
-
training_parameters=self._parameter_vector,
|
|
158
|
-
evaluate_duplicates=self._evaluate_duplicates,
|
|
159
|
-
enforce_psd=False,
|
|
160
|
-
)
|
|
161
|
-
else:
|
|
162
|
-
raise RuntimeError("Invalid quantum framework!")
|
|
181
|
+
raise RuntimeError("Invalid quantum framework!")
|
|
163
182
|
|
|
164
183
|
def get_params(self, deep: bool = True) -> dict:
|
|
165
184
|
"""
|
|
@@ -263,7 +282,6 @@ class FidelityKernel(KernelMatrixBase):
|
|
|
263
282
|
"Parameters have to been set with assign_parameters or as initial parameters!"
|
|
264
283
|
)
|
|
265
284
|
self._quantum_kernel.assign_training_parameters(self._parameters)
|
|
266
|
-
|
|
267
285
|
kernel_matrix = self._quantum_kernel.evaluate(x, y)
|
|
268
286
|
|
|
269
287
|
if self._mit_depol_noise is not None:
|
|
@@ -285,6 +303,36 @@ class FidelityKernel(KernelMatrixBase):
|
|
|
285
303
|
kernel_matrix = self._regularize_matrix(kernel_matrix)
|
|
286
304
|
return kernel_matrix
|
|
287
305
|
|
|
306
|
+
def evaluate_derivatives(
|
|
307
|
+
self, x: np.ndarray, y: np.ndarray = None, values: Union[str, tuple] = "dKdx"
|
|
308
|
+
) -> dict:
|
|
309
|
+
"""Evaluates the Fidelity Kernel and its derivatives for the given data points x and y.
|
|
310
|
+
|
|
311
|
+
Args:
|
|
312
|
+
x (np.ndarray): Data points x
|
|
313
|
+
y (np.ndarray): Data points y, if None y = x is used
|
|
314
|
+
values (Union[str, tuple]): Values to evaluate. Can be a string or a tuple of strings.
|
|
315
|
+
Possible values are:
|
|
316
|
+
``dKdx``, ``dKdy``, ``dKdxdx``, ``dKdydy``, ``dKdxdy``, ``dKdydx``, ``dKdp``
|
|
317
|
+
and ``jacobian``.
|
|
318
|
+
Returns:
|
|
319
|
+
Dictionary with the evaluated values
|
|
320
|
+
"""
|
|
321
|
+
|
|
322
|
+
if self._parameter_vector is not None:
|
|
323
|
+
if self._parameters is None:
|
|
324
|
+
raise ValueError(
|
|
325
|
+
"Parameters have to been set with assign_parameters or as initial parameters!"
|
|
326
|
+
)
|
|
327
|
+
self._quantum_kernel.assign_training_parameters(self._parameters)
|
|
328
|
+
|
|
329
|
+
if self._use_expectation:
|
|
330
|
+
return self._quantum_kernel.evaluate_derivatives(x, y, values)
|
|
331
|
+
else:
|
|
332
|
+
raise NotImplementedError(
|
|
333
|
+
"Derivatives are only implemented for the option use expectation=True"
|
|
334
|
+
)
|
|
335
|
+
|
|
288
336
|
def _get_msplit_kernel(self, kernel: np.ndarray) -> np.ndarray:
|
|
289
337
|
"""Function to mitigate depolarizing noise using msplit method.
|
|
290
338
|
|