Gradient#
- class qiskit.opflow.gradients.Gradient(grad_method='param_shift', **kwargs)[fuente]#
Bases:
GradientBase
Deprecated: Convert an operator expression to the first-order gradient.
Obsoleto desde la versión 0.24.0: The class
qiskit.opflow.gradients.gradient.Gradient
is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. For code migration guidelines, visit https://qisk.it/opflow_migration.Attributes
- grad_method#
Returns
CircuitGradient
.- Devuelve:
CircuitGradient
.
Methods
- convert(operator, params=None)[fuente]#
- Parámetros:
operator (OperatorBase) – The operator we are taking the gradient of.
params (ParameterVector | ParameterExpression | List[ParameterExpression] | None) – The parameters we are taking the gradient with respect to. If not explicitly passed, they are inferred from the operator and sorted by name.
- Devuelve:
An operator whose evaluation yields the Gradient.
- Muestra:
ValueError – If
params
contains a parameter not present inoperator
.ValueError – If
operator
is not parameterized.
- Tipo del valor devuelto:
- get_gradient(operator, params)[fuente]#
Get the gradient for the given operator w.r.t. the given parameters
- Parámetros:
operator (OperatorBase) – Operator w.r.t. which we take the gradient.
params (ParameterExpression | ParameterVector | List[ParameterExpression]) – Parameters w.r.t. which we compute the gradient.
- Devuelve:
Operator which represents the gradient w.r.t. the given params.
- Muestra:
ValueError – If
params
contains a parameter not present inoperator
.OpflowError – If the coefficient of the operator could not be reduced to 1.
OpflowError – If the differentiation of a combo_fn requires JAX but the package is not installed.
TypeError – If the operator does not include a StateFn given by a quantum circuit
Exception – Unintended code is reached
MissingOptionalLibraryError – jax not installed
- Tipo del valor devuelto: