How to use the pennylane.qnode function in PennyLane

To help you get started, we’ve selected a few PennyLane examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github XanaduAI / pennylane / tests / test_default_gaussian.py View on Github external
        @qml.qnode(gaussian_dev)
        def circuit(*x):
            """Reference quantum function"""
            qml.Displacement(a, 0, wires=[0])
            op(*x, wires=wires)
            return qml.expval(qml.X(0))
github XanaduAI / pennylane / tests / test_observable.py View on Github external
    @qml.qnode(dev)
    def circuit():
        return qml.expval(qml.Identity(0))
github rigetti / pennylane-forest / tests / test_qpu.py View on Github external
        @qml.qnode(dev_qpu)
        def circuit_Zmi():
            qml.RX(np.pi, wires=qubit)
            return qml.expval(qml.PauliZ(qubit))
github XanaduAI / pennylane / tests / test_operation.py View on Github external
        @qml.qnode(dev1)
        def mean_photon_gaussian(mag_alpha, phase_alpha, phi):
            qml.Displacement(mag_alpha, phase_alpha, wires=0)
            qml.Rotation(phi, wires=0).inv()
            return qml.expval(qml.NumberOperator(0))
github XanaduAI / pennylane / tests / test_qnode.py View on Github external
        @qml.qnode(dev)
        def circuit1(x):
            qml.RX(x, wires=0)
            qml.CRX(x, wires=[0, 1])
            return qml.expval(qml.PauliZ(0))
github XanaduAI / pennylane / examples / pennylane_run_state_preparation.py View on Github external
@qml.qnode(dev)
def circuit(params, A=None):

    # repeatedly apply each layer in the circuit
    for j in range(nr_layers):
        layer(params, j)

    # returns the expectation of the input matrix A on the first qubit
    return qml.expval(qml.Hermitian(A, wires=0))
github XanaduAI / pennylane / examples / Q3a_variational-classifier-parity.py View on Github external
@qml.qnode(dev)
def circuit(weights, x=None):
    """The circuit of the variational classifier.

    Args:
        weights (array[float]): array of variables
        x: single input vector

    Returns:
        expectation of Pauli-Z operator on Qubit 0
    """

    statepreparation(x)

    for W in weights:
        layer(W)
github XanaduAI / qml / demonstrations / tutorial_noisy_circuit_optimization.py View on Github external
@qml.qnode(dev)
def measure_A1B2():
    bell_pair()
    return qml.expval(A1 @ B2)
github XanaduAI / qml / implementations / tutorial_variational_quantum_eigensolver.py View on Github external
@qml.qnode(dev)
def circuit_Y(var):
    ansatz(var)
    return qml.expval(qml.PauliY(1))
github XanaduAI / qml / demonstrations / tutorial_qubit_rotation.py View on Github external
@qml.qnode(dev1)
def circuit2(phi1, phi2):
    qml.RX(phi1, wires=0)
    qml.RY(phi2, wires=0)
    return qml.expval(qml.PauliZ(0))

PennyLane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.

Apache-2.0
Latest version published 3 days ago

Package Health Score

87 / 100
Full package analysis