quairkit.ansatz.comb¶
The source file of the PQCombNet class.
-
class quairkit.ansatz.comb.PQCombNet(target_function, num_slots, num_aux_qubits, num_qubits_U=
1
, train_unitary_info=200
, test_unitary_info=1000
, train_mode='choi'
, LR=0.1
, NUM_ITR=1000
, name_task=None
, seed=None
, is_save_data=False
, is_auto_stop=True
, is_ctrl_U=False
)¶ Parameterized Quantum Comb Net.
- Parameters:¶
- target_function : Callable[[Tensor], Tensor]¶
The function to apply to each tensor in the dataset.
- num_slots : int¶
The parameter ‘num_slots’ used in the specific quantum computation context.
- num_aux_qubits : int¶
The parameter ‘num_aux_qubits’ also used in the quantum computation context.
- num_qubits_U : int¶
The number of qubits of the unitaries to be queried.
- train_unitary_info : int | Tensor¶
Information for generating or providing training unitaries, either as an integer or a tensor.
- test_unitary_info : int | Tensor¶
Information for generating or providing testing unitaries, similar to train_unitary_info.
- train_mode : str¶
The mode to use for training, default is ‘choi’.
- LR : float¶
Learning rate for the optimization algorithm.
- NUM_ITR : int¶
Number of iterations to run the training.
- name_task : str¶
Optional name for the task, useful for data logging and storage.
- seed : int | None¶
Optional seed for random number generation, enhancing reproducibility.
- is_save_data : bool¶
Flag to determine if data should be saved during training.
- is_auto_stop : bool¶
Flag to enable stopping the training process automatically based on certain criteria.
- is_ctrl_U : bool¶
Flag to indicate if a controlled-U operation is used in the training process.
- update_V_circuit(index, new_V)¶
Update the V circuit at the specified index with a new circuit.
- Parameters:¶
- index : int¶
The index of the V circuit to update.
- new_V : Circuit | ParamOracle | Tensor | Tuple[Tensor, List[int]]¶
The new V circuit, which can be a ParamOracle, Circuit, torch.Tensor or Tuple[torch.Tensor, List[int]].
- Raises:¶
ValueError – If the index is out of range or if the number of qubits in the provided Circuit does not match the number of qubits in the existing Circuit.
TypeError – If new_V is not a ParamOracle, Circuit, torch.Tensor or Tuple[torch.Tensor, List[int]].
- train()¶
Train the PQCombNet model.
- extract_highest_fidelity()¶
Call the _extract_highest_fidelity function to generate the fidelity tables. If the file does not exist, prompt the user to set is_save_data to True.