Skip to content

Commit 4abc430

Browse files
Debug
1 parent f86627d commit 4abc430

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/tfim_vqe.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,16 @@ def circuit(delta):
337337
print(weights)
338338

339339
# Step 7: Finish calculating energy expectation value with VQE
340-
opt = qml.AdamOptimizer(stepsize=(np.pi / 60))
341-
min_energy = circuit(weights)
340+
best_weights = weights.copy()
341+
opt = qml.AdamOptimizer(stepsize=(np.pi / 120))
342342
for i in range(20):
343343
weights = opt.step(lambda w: circuit(w), weights)
344344
energy = circuit(weights)
345345
print(f"Step {i+1}: Energy = {energy}")
346346
if energy < min_energy:
347347
min_energy = energy
348+
best_weights = weights.copy()
348349

349350
print(f"Optimized Ground State Energy: {min_energy} Ha")
350351
print("Optimized parameters:")
351-
print(weights)
352+
print(best_weights)

0 commit comments

Comments
 (0)