We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f86627d commit 4abc430Copy full SHA for 4abc430
scripts/tfim_vqe.py
@@ -337,15 +337,16 @@ def circuit(delta):
337
print(weights)
338
339
# Step 7: Finish calculating energy expectation value with VQE
340
-opt = qml.AdamOptimizer(stepsize=(np.pi / 60))
341
-min_energy = circuit(weights)
+best_weights = weights.copy()
+opt = qml.AdamOptimizer(stepsize=(np.pi / 120))
342
for i in range(20):
343
weights = opt.step(lambda w: circuit(w), weights)
344
energy = circuit(weights)
345
print(f"Step {i+1}: Energy = {energy}")
346
if energy < min_energy:
347
min_energy = energy
348
+ best_weights = weights.copy()
349
350
print(f"Optimized Ground State Energy: {min_energy} Ha")
351
print("Optimized parameters:")
-print(weights)
352
+print(best_weights)
0 commit comments