Constructors
This module implements the constructor class.
build_qnn_from_configs(register, observable_config, fm_config=FeatureMapConfig(), ansatz_config=AnsatzConfig(), backend=BackendName.PYQTORCH, diff_mode=DiffMode.AD, measurement=None, noise=None, configuration=None, input_diff_mode=InputDiffMode.AD)
Build a QNN model.
PARAMETER | DESCRIPTION |
---|---|
register
|
Number of qubits or a register object.
TYPE:
|
observable_config
|
Observable configuration(s).
TYPE:
|
fm_config
|
Feature map configuration.
TYPE:
|
ansatz_config
|
Ansatz configuration.
TYPE:
|
backend
|
The chosen quantum backend.
TYPE:
|
diff_mode
|
The differentiation engine to use. Choices are 'gpsr' or 'ad'.
TYPE:
|
measurement
|
Optional measurement protocol. If None, use exact expectation value with a statevector simulator.
TYPE:
|
noise
|
A noise model to use.
TYPE:
|
configuration
|
Optional backend configuration.
TYPE:
|
input_diff_mode
|
The differentiation mode for the input tensor.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
QNN
|
A QNN model.
TYPE:
|
Source code in qadence_model/models/qnn_constructors.py
create_ansatz(register, config)
Create the ansatz based on the configuration.
PARAMETER | DESCRIPTION |
---|---|
register
|
Number of qubits or a register object.
TYPE:
|
config
|
Configuration for the ansatz.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AbstractBlock
|
The ansatz block.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
NotImplementedError
|
If the ansatz type is not implemented. |
Source code in qadence_model/models/qnn_constructors.py
create_fm_blocks(register, config)
Create a list of feature map blocks based on the given configuration.
In case of series encoding or even parallel encoding with data reuploads, the outputs is a list of blocks that still need to be interleaved with non commuting blocks.
PARAMETER | DESCRIPTION |
---|---|
register
|
The number of qubits or the register.
TYPE:
|
config
|
The configuration for the feature map.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[AbstractBlock]
|
list[AbstractBlock]: A list of feature map blocks. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the feature map strategy is not |
Source code in qadence_model/models/qnn_constructors.py
create_observable(register, config)
Create an observable block.
PARAMETER | DESCRIPTION |
---|---|
register
|
Number of qubits or a register object.
TYPE:
|
config
|
Observable configuration.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AbstractBlock
|
The observable block.
TYPE:
|