@@ -143,39 +143,52 @@ def __init__(
143
143
input_gradients : bool = False ,
144
144
pass_manager : BasePassManager | None = None ,
145
145
):
146
- """
147
- Args: sampler: The sampler primitive used to compute the neural network's results. If
148
- ``None`` is given, a default instance of the reference sampler defined by
149
- :class:`~qiskit.primitives.Sampler` will be used. circuit: The parametrized quantum
150
- circuit that generates the samples of this network. If a
151
- :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` is passed,
152
- the `input_params` and `weight_params` do not have to be provided, because these two
153
- properties are taken from the :class:`~qiskit_machine_learning.circuit.library.QNNCircuit
154
- `. input_params: The parameters of the circuit corresponding to the input. If a
155
- :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` is provided the
156
- `input_params` value here is ignored. Instead, the value is taken from the
157
- :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` input_parameters.
158
- weight_params: The parameters of the circuit corresponding to the trainable weights. If a
159
- :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` is provided the
160
- `weight_params` value here is ignored. Instead, the value is taken from the
161
- :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` weight_parameters. sparse:
162
- Returns whether the output is sparse or not. interpret: A callable that maps the measured
163
- integer to another unsigned integer or tuple of unsigned integers. These are used as new
164
- indices for the (potentially sparse) output array. If no interpret function is passed,
165
- then an identity function will be used by this neural network. output_shape: The output
166
- shape of the custom interpretation. For SamplerV1, it is ignored if no custom interpret
167
- method is provided where the shape is taken to be ``2^circuit.num_qubits``. gradient: An
168
- optional sampler gradient to be used for the backward pass. If ``None`` is given,
169
- a default instance of
170
- :class:`~qiskit_machine_learning.gradients.ParamShiftSamplerGradient` will be used.
171
- input_gradients: Determines whether to compute gradients with respect to input data. Note
172
- that this parameter is ``False`` by default, and must be explicitly set to ``True`` for a
173
- proper gradient computation when using
174
- :class:`~qiskit_machine_learning.connectors.TorchConnector`.
175
- pass_manager: The pass manager to transpile the circuits, if necessary.
176
- Defaults to ``None``, as some primitives do not need transpiled circuits.
146
+ r"""
147
+ Args:
148
+ circuit: The parametrized quantum
149
+ circuit that generates the samples of this network. If a
150
+ :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` is passed,
151
+ the `input_params` and `weight_params` do not have to be provided, because these two
152
+ properties are taken from the
153
+ :class:`~qiskit_machine_learning.circuit.library.QNNCircuit`.
154
+ sampler: The sampler primitive used to compute the neural network's results. If
155
+ ``None`` is given, a default instance of the reference sampler defined by
156
+ :class:`~qiskit.primitives.Sampler` will be used.
157
+
158
+ .. warning::
159
+
160
+ The assignment ``sampler=None`` defaults to using
161
+ :class:`~qiskit.primitives.Sampler`, which points to a deprecated Sampler V1
162
+ (as of Qiskit 1.2). ``SamplerQNN`` will adopt Sampler V2 as default no later than
163
+ Qiskit Machine Learning 0.9.
164
+
165
+ input_params: The parameters of the circuit corresponding to the input. If a
166
+ :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` is provided the
167
+ `input_params` value here is ignored. Instead, the value is taken from the
168
+ :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` input_parameters.
169
+ weight_params: The parameters of the circuit corresponding to the trainable weights. If a
170
+ :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` is provided the
171
+ `weight_params` value here is ignored. Instead, the value is taken from the
172
+ :class:`~qiskit_machine_learning.circuit.library.QNNCircuit` ``weight_parameters``.
173
+ sparse: Returns whether the output is sparse or not.
174
+ interpret: A callable that maps the measured integer to another unsigned integer or tuple
175
+ of unsigned integers. These are used as new indices for the (potentially sparse)
176
+ output array. If no interpret function is passed, then an identity function will be
177
+ used by this neural network.
178
+ output_shape: The output shape of the custom interpretation. For SamplerV1, it is ignored
179
+ if no custom interpret method is provided where the shape is taken to be
180
+ ``2^circuit.num_qubits``.
181
+ gradient: An optional sampler gradient to be used for the backward pass. If ``None`` is
182
+ given, a default instance of
183
+ :class:`~qiskit_machine_learning.gradients.ParamShiftSamplerGradient` will be used.
184
+ input_gradients: Determines whether to compute gradients with respect to input data. Note
185
+ that this parameter is ``False`` by default, and must be explicitly set to ``True``
186
+ for a proper gradient computation when using
187
+ :class:`~qiskit_machine_learning.connectors.TorchConnector`.
188
+ pass_manager: The pass manager to transpile the circuits, if necessary.
189
+ Defaults to ``None``, as some primitives do not need transpiled circuits.
177
190
Raises:
178
- QiskitMachineLearningError: Invalid parameter values.
191
+ QiskitMachineLearningError: Invalid parameter values.
179
192
"""
180
193
# set primitive, provide default
181
194
if sampler is None :
0 commit comments