Operation#
- class torchquantum.operator.Operation(has_params: bool = False, trainable: bool = False, init_params=None, n_wires=None, wires=None, inverse=False)[source]#
Bases:
Operator
_summary_
- __init__(has_params: bool = False, trainable: bool = False, init_params=None, n_wires=None, wires=None, inverse=False)[source]#
_summary_
- Parameters:
has_params (bool, optional) – Whether the operations has parameters. Defaults to False.
trainable (bool, optional) – Whether the parameters are trainable (if contains parameters). Defaults to False.
init_params (torch.Tensor, optional) – Initial parameters. Defaults to None.
n_wires (int, optional) – Number of qubits. Defaults to None.
wires (Union[int, List[int]], optional) – Which qubit the operation is applied to. Defaults to None.
Methods
- build_params(trainable)[source]#
Build parameters.
- Parameters:
trainable (bool) – Whether the parameters are trainable.
- Returns:
Built parameters.
- Return type:
torch.Tensor
- init_params()[source]#
Initialize the parameters.
- Raises:
NotImplementedError – The init param function is not implemented.
- reset_params(init_params=None)[source]#
Reset parameters.
- Parameters:
init_params (torch.Tensor, optional) – Input the initialization parameters. Defaults to None.
Attributes
- eigvals#
“The eigenvalues of the unitary matrix of the operator.
- Returns:
Eigenvalues.
- Return type:
torch.Tensor
- matrix#
The unitary matrix of the operator.