示例#1
0
    def test_random_layers_nlayers(self, n_layers):
        """Test that RandomLayers() picks the correct number of gates."""
        np.random.seed(12)
        n_rots = 1
        n_wires = 2
        impr = CNOT
        weights = np.random.randn(n_layers, n_rots)

        with pennylane._queuing.OperationRecorder() as rec:
            RandomLayers(weights=weights, wires=range(n_wires))

        types = [type(q) for q in rec.queue]
        assert len(types) - types.count(impr) == n_layers
    def test_random_layers_nlayers(self, n_layers):
        """Test that RandomLayers() picks the correct number of gates."""
        np.random.seed(12)
        n_rots = 1
        n_wires = 2
        impr = CNOT
        dev = qml.device('default.qubit', wires=n_wires)
        weights = np.random.randn(n_layers, n_rots)

        with qml.utils.OperationRecorder() as rec:
            RandomLayers(weights=weights, wires=range(n_wires))

        types = [type(q) for q in rec.queue]
        assert len(types) - types.count(impr) == n_layers
示例#3
0
 def circuit(phi):
     RandomLayers(phi, wires=list(range(4)))
     return qml.expval(qml.PauliZ(0))
示例#4
0
 def circuit(weights):
     RandomLayers(weights=weights, wires=range(2), seed=None)
     return qml.expval(qml.PauliZ(0))
示例#5
0
 def circuit(weights):
     RandomLayers(weights=weights, wires=range(n_wires))
     return qml.expval(qml.PauliZ(0))
示例#6
0
            def circuit(phi=None):

                # Random quantum circuit
                RandomLayers(phi, wires=list(range(4)))

                return qml.expval(qml.PauliZ(0))
示例#7
0
 def circuit(weights):
     RandomLayers(weights, wires=range(n_wires))
     return ret_type(qml.PauliZ(wires=0) @ qml.PauliX(wires=1))
示例#8
0
 def circuit2(weights):
     RandomLayers(weights=weights, wires=range(n_wires), seed=seed)
     return qml.expval.PauliZ(0)
示例#9
0
 def circuit(weights):
     RandomLayers(*weights, wires=range(n_subsystems))
     return qml.expval.Identity(0)