MCPcopy Create free account
hub / github.com/Apress/quantum-machine-learning-python / run

Method run

Chapter_6/listing6_1/QCNN.py:33–44  ·  view source on GitHub ↗
(self, theta_batch)

Source from the content-addressed store, hash-verified

31 self.copies = copies
32
33 def run(self, theta_batch):
34 job = qiskit.execute(self._circuit_,
35 self.backend,
36 shots=self.copies,
37 parameter_binds=[{self.theta: theta} for theta in theta_batch])
38 result = job.result().get_counts(self._circuit_)
39
40 counts = np.array(list(result.values()))
41 states = np.array(list(result.keys())).astype(float)
42 probs = counts / self.copies
43 expectation = np.array([np.sum(np.multiply(probs, states))])
44 return expectation
45
46
47class QuantumFunction(Function):

Callers 15

forwardMethod · 0.45
backwardMethod · 0.45
compute_expectationFunction · 0.45
VQE_routineFunction · 0.45
simulate_circuitMethod · 0.45
random_number_generatorFunction · 0.45
mainFunction · 0.45
listing_3.4.pyFile · 0.45
simons_algorithm_circuitFunction · 0.45
deutsch_jozsaFunction · 0.45
BV_algorithmFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected