RawFeatureVector¶
-
class
RawFeatureVector
(feature_dimension)[source]¶ Bases:
qiskit.circuit.library.blueprintcircuit.BlueprintCircuit
The raw feature vector circuit.
This circuit acts as parameterized initialization for statevectors with
feature_dimension
dimensions, thus withlog2(feature_dimension)
qubits. As long as there are free parameters, this circuit holds a placeholder instruction and can not be decomposed. Once all parameters are bound, the placeholder is replaced by a state initialization and can be unrolled.In ML, this circuit can be used to load the training data into qubit amplitudes. It does not apply an kernel transformation. (Therefore, it is a “raw” feature vector.)
Examples:
from qiskit.ml.circuit.library import RawFeatureVector circuit = RawFeatureVector(4) print(circuit.num_qubits) # prints: 2 print(circuit.draw(output='text')) # prints: # ┌──────┐ # q_0: ┤0 ├ # │ Raw │ # q_1: ┤1 ├ # └──────┘ print(circuit.ordered_parameters) # prints: [Parameter(p[0]), Parameter(p[1]), Parameter(p[2]), Parameter(p[3])] import numpy as np state = np.array([1, 0, 0, 1]) / np.sqrt(2) bound = circuit.assign_parameters(state) print(bound.draw()) # prints: # ┌──────────────────────────────────┐ # q_0: ┤0 ├ # │ initialize(0.70711,0,0,0.70711) │ # q_1: ┤1 ├ # └──────────────────────────────────┘
- Parameters
feature_dimension (
Optional
[int
]) – The feature dimension and number of qubits.
Methods
Add Bits to the circuit.
Register a low-level, custom pulse definition for the given gate.
Add registers.
Append one or more instructions to the end of the circuit, modifying the circuit in place.
Call the initialize instruction.
Apply
Barrier
.Bind parameters.
Best effort to cast value to type.
Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits.
Apply
CCXGate
.Apply
CHGate
.Return the current number of instances of this class, useful for auto naming.
Return the prefix to use for auto naming.
Apply
CXGate
.DEPRECATED - Returns rhs appended to self if self contains compatible registers.
Compose circuit with
other
circuit or instruction, optionally permuting wires.Control this circuit on
num_ctrl_qubits
qubits.Copy the circuit.
Count each operation kind in the circuit.
Apply
CPhaseGate
.Apply
CRXGate
.Apply
CRYGate
.Apply
CRZGate
.Apply
CSwapGate
.Apply
CSXGate
.Apply
CUGate
.Apply
CU1Gate
.Apply
CU3Gate
.Apply
CXGate
.Apply
CYGate
.Apply
CZGate
.Apply
DCXGate
.Call a decomposition pass on this circuit, to decompose one level (shallow decompose).
Apply
Delay
.Return circuit depth (i.e., length of critical path).
Attach a diagonal gate to a circuit.
Draw the quantum circuit.
Apply
ECRGate
.DEPRECATED - Append QuantumCircuit to the RHS if it contains compatible registers.
Apply
CSwapGate
.Take in a QASM file and generate a QuantumCircuit object.
Take in a QASM string and generate a QuantumCircuit object.
Get instructions matching name.
Apply
HGate
.Apply hamiltonian evolution to qubits.
Test if this circuit has the register r.
Apply
IGate
.Apply
IGate
.Initialize qubits in a specific state.
Invert (take adjoint of) this circuit.
Attach an arbitrary isometry from m to n qubits to a circuit.
Attach an arbitrary isometry from m to n qubits to a circuit.
Apply
iSwapGate
.Apply
MCPhaseGate
.Apply Multiple-Controlled X rotation gate
Apply Multiple-Controlled Y rotation gate
Apply Multiple-Controlled Z rotation gate
Apply
MCXGate
.Apply
MCU1Gate
.Apply
MCXGate
.Measure quantum bit into classical bit (tuples).
Adds measurement to all non-idle qubits.
Adds measurement to all qubits.
Apply
MSGate
.How many non-entangled subcircuits can the circuit be factored to.
Return number of non-local gates (i.e.
Computes the number of tensor factors in the unitary (quantum) part of the circuit only.
Computes the number of tensor factors in the unitary (quantum) part of the circuit only.
Apply
PhaseGate
.Apply
PauliGate
.Raise this circuit to the power of
power
.Return OpenQASM string.
Converts several qubit representations (such as indexes, range, etc.) into a list of qubits.
Return the duration between the start and stop time of the first and last instructions, excluding delays, over the supplied qubits.
Return the start time of the first instruction, excluding delays, over the supplied qubits.
Return the stop time of the last instruction, excluding delays, over the supplied qubits.
Apply
RGate
.Apply
RC3XGate
.Apply
RCCXGate
.Removes final measurement on all qubits if they are present.
Repeat this circuit
reps
times.Reset q.
Return a circuit with the opposite order of wires.
Reverse the circuit by reversing the order of instructions.
Apply
RVGate
.Apply
RXGate
.Apply
RXXGate
.Apply
RYGate
.Apply
RYYGate
.Apply
RZGate
.Apply
RZXGate
.Apply
RZZGate
.Apply
SGate
.Save complex statevector amplitudes.
Save squared statevector amplitudes (probabilities).
Save the current simulator quantum state as a density matrix.
Save the expectation value of a Hermitian operator.
Save the expectation value of a Hermitian operator.
Save the current simulator quantum state as a matrix product state.
Save measurement outcome probabilities vector.
Save measurement outcome probabilities vector.
Save the current stabilizer simulator quantum state as a Clifford.
Save the current simulator quantum state.
Save the current simulator quantum state as a statevector.
Save the current simulator quantum state as a statevector as a dict.
Save the current state of the superop simulator.
Save the current state of the unitary simulator.
Apply
SdgGate
.Set the density matrix state of the simulator.
Set the matrix product state of the simulator.
Set the Clifford stabilizer state of the simulator.
Set the statevector state of the simulator.
Set the superop state of the simulator.
Set the state state of the simulator.
Returns total number of gate operations in circuit.
Take a statevector snapshot of the internal simulator representation.
Take a density matrix snapshot of simulator state.
Take a snapshot of expectation value <O> of an Operator.
Take a probability snapshot of the simulator state.
Take a stabilizer snapshot of the simulator state.
Take a statevector snapshot of the simulator state.
Decompose an arbitrary 2*2 unitary into three rotation gates.
Apply
SwapGate
.Apply
SXGate
.Apply
SXdgGate
.Apply
TGate
.Apply
TdgGate
.Tensor
self
withother
.Create a Gate out of this circuit.
Create an Instruction out of this circuit.
Apply
CCXGate
.Apply
UGate
.Apply
U1Gate
.Apply
U2Gate
.Apply
U3Gate
.Attach a uniformly controlled gates (also called multiplexed gates) to a circuit.
Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit.
Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit.
Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit.
Apply unitary gate to q.
Return number of qubits plus clbits in circuit.
Apply
XGate
.Apply
YGate
.Apply
ZGate
.Attributes
-
ancillas
¶ Returns a list of ancilla bits in the order that the registers were added.
-
calibrations
¶ Return calibration dictionary.
- The custom pulse definition of a given gate is of the form
{‘gate_name’: {(qubits, params): schedule}}
-
clbits
¶ Returns a list of classical bits in the order that the registers were added.
-
data
¶
-
extension_lib
= 'include "qelib1.inc";'¶
-
feature_dimension
¶ Return the feature dimension.
- Return type
int
- Returns
The feature dimension, which is
2 ** num_qubits
.
-
global_phase
¶ Return the global phase of the circuit in radians.
-
header
= 'OPENQASM 2.0;'¶
-
instances
= 16¶
-
metadata
¶ The user provided metadata associated with the circuit
The metadata for the circuit is a user provided
dict
of metadata for the circuit. It will not be used to influence the execution or operation of the circuit, but it is expected to be passed between all transforms of the circuit (ie transpilation) and that providers will associate any circuit metadata with the results it returns from execution of that circuit.
-
num_ancillas
¶ Return the number of ancilla qubits.
-
num_clbits
¶ Return number of classical bits.
-
num_parameters
¶ - Return type
int
-
num_qubits
¶ Returns the number of qubits in this circuit.
- Return type
int
- Returns
The number of qubits.
-
ordered_parameters
¶ Return the free parameters in the RawFeatureVector.
- Return type
List
[ParameterExpression
]- Returns
A list of the free parameters.
-
parameters
¶ Return the free parameters in the RawFeatureVector.
- Return type
Set
[ParameterExpression
]- Returns
A set of the free parameters.
-
prefix
= 'circuit'¶
-
qregs
¶ A list of the quantum registers associated with the circuit.
-
qubits
¶ Returns a list of quantum bits in the order that the registers were added.