Parameter
QuICT.core.utils.Parameter ¶
Used to represent trainable parameters of parameterized quantum gates or parameterized quantum circuits.
Note
Only supports number multiplication operation.
Parameters:
-
symbol(str) –The symbol.
Examples:
>>> from QuICT.core.circuit import Circuit
>>> from QuICT.core.gate import *
>>> cir = Circuit(3)
>>> H | cir
>>> Rx("x") | cir(0)
>>> Rx(Parameter("x") * 0.3) | cir(2)
>>> Rzz("y") | cir([0, 1])
>>> cir.draw("command")
┌───┐ ┌───────┐
q_0: |0>┤ h ├─┤ rx(x) ├───■──────
├───┤ └───────┘ │ZZ(y)
q_1: |0>┤ h ├─────────────■──────
├───┤┌──────────┐
q_2: |0>┤ h ├┤ rx(0.3x) ├────────
└───┘└──────────┘
Initialize a Parameter instance.
Source code in QuICT/core/utils/parameter.py
dx
property
¶
The derivative of the parameter on the symbol.
Returns:
-
float(float) –The derivative.
expr
property
¶
The expression of the parameter.
Returns:
-
str(str) –The expression of the parameter.
multiplier
property
¶
The multiplier of the symbol.
Returns:
-
float(float) –The multiplier.
__lt__ ¶
Determine whether the current parameter is smaller than another parameter.
Parameters:
-
other(Parameter) –Another parameter.
Returns:
-
bool–If True, the current parameter is smaller than another parameter.
Source code in QuICT/core/utils/parameter.py
__mul__ ¶
Multiply a number.
Parameters:
-
other(Number) –The multiplier.
Returns:
-
Parameter–The new parameter after number multiplication operation.
Source code in QuICT/core/utils/parameter.py
__rmul__ ¶
Multiply a number.
Parameters:
-
other(Number) –The multiplier.
Returns:
-
Parameter–The new parameter after number multiplication operation.