mindquantum.core.circuit.as_encoder
- mindquantum.core.circuit.as_encoder(circuit_fn)[source]
Conversion decorator of a circuit to an encoder circuit.
- Parameters
circuit_fn (Union[Circuit, FunctionType, MethodType]) – A Circuit or a callable function that can return a Circuit.
- Returns
Function, if circuit_fn is a callable function that will return a Circuit. Circuit, if circuit_fn is already a Circuit.
Examples
>>> from mindquantum.core.circuit import as_encoder, Circuit >>> from mindquantum.core.gates import RX >>> @as_encoder ... def create_circuit(): ... circ = Circuit() ... circ += RX('a').on(0) ... return circ >>> circ = create_circuit() >>> circ.encoder_params_name ['a'] >>> circ.as_ansatz() >>> circ.encoder_params_name [] >>> circ = as_encoder(circ) >>> circ.encoder_params_name ['a']