FrozenParameterGate
- class FrozenParameterGate[source]
Bases:
ComposedGate
,LocallyOptimizableUnitary
,DifferentiableUnitary
A composed gate which fixes some parameters of another gate.
- __init__(gate, frozen_params)[source]
Create a gate which fixes some of the parameters it takes.
- Parameters:
gate (
Gate
) – The Gate to fix the parameters of.frozen_params (
dict[int, float]
) – A dictionary mapping parameters indices to the fixed value they should be.
- Raises:
ValueError – If any of the frozen_params indices are greater than the number of parameters gate takes or less than 0 or if the total amount of frozen_params is larger than the number of parameters gate takes.
Attributes
The matrix dimension for this unitary.
The name of this gate.
The number of real parameters this unitary-valued function takes.
The number of qudits this unitary can act on.
The qasm command for this gate, see Gate for more info.
The number of orthogonal states for each qudit.
Methods
check_env_matrix
(env_matrix)Check to ensure the env_matrix is validly shaped.
check_parameters
(params)Check parameters are valid and match the unitary.
get_full_params
(params)Returns the full parameter list for the underlying gate.
get_grad
([params])Return the gradient for this gate.
Return the gate's inverse as a gate.
get_inverse_params
([params])Return the parameters that invert the gate.
get_qasm
(params, location)Returns the qasm string for this gate.
Returns a qasm def for this gate, see :class:Gate for more.
get_unitary
([params])Return the unitary for this gate, see
Unitary
for more.get_unitary_and_grad
([params])Return the unitary and gradient for this gate.
Return true if this unitary doesn't take parameters.
Check if all sub gates are differentiable.
Check if all sub gates are locally optimizable.
Return true if this unitary is parameterized.
Return true if this unitary can only act on qubits.
is_qudit_only
(radix)Return true if this unitary can only act on radix-qudits.
Return true if this unitary can only act on qutrits.
is_self_inverse
([params])Checks whether the unitary is its own inverse.
optimize
(env_matrix)Return the optimal parameters with respect to an environment matrix.
with_all_frozen_params
(params)Freeze all of a gate's parameters so they don't change from optimization.
with_frozen_params
(frozen_params)Freeze some of a gate's parameters so they don't change from optimization.