Skip to content

Commit

Permalink
update save each steps
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyang-ustc committed Sep 9, 2024
1 parent ef20439 commit 7a71680
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.pbs
jobs/*
*.tar
data/**
*.prof
*.h5
__pycache__
Expand Down
1 change: 1 addition & 0 deletions conf/gfpeps/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ file:
LoadFile: "./data/default.h5" # Load initial T from this file, if it exists
# LoadFile: ""
WriteFile: "./data/default.h5" # Write information about final Gaussian fPEPS to this file
SaveEachSteps: True

optimizer:
MaxIter: 100
Expand Down
9 changes: 7 additions & 2 deletions src/gfpeps/gaussian_fpeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def euclidean_hessian(x,y):
result = solver.run(problem, initial_point=T)
log_cost = np.array(result.log["iterations"]["cost"])
log_gnorm = np.array(result.log["iterations"]["gradient_norm"])

logging.info("Iterations \t Cost \t Gradient Norm")
for iter in range(len(log_cost)):
logging.info(f"{iter} \t {log_cost[iter]} \t {log_gnorm[iter]}")
Expand All @@ -87,5 +87,10 @@ def euclidean_hessian(x,y):
Xopt = result.point
args = {"Mu":Mu,"DeltaX":DeltaX,"DeltaY":DeltaY,"delta":delta,
"ht":ht,"Lx":Lx,"Ly":Ly,"Nv":Nv,"seed":cfg.params.seed}
savelog_trivial(WriteKey,Xopt,lossT(Xopt),Eg,args, measure(cfg,result.point))
savelog_trivial(WriteKey,Xopt,lossT(Xopt),Eg,args, measure(cfg,Xopt))

if cfg.file.SaveEachSteps:
for iter in range(len(log_cost)):
Xopt = np.array(result.log["iterations"]["point"])[iter]
savelog_trivial(WriteKey[:-3]+f"-iter{iter}"+WriteKey[-3:],Xopt,lossT(Xopt), Eg, args, measure(cfg, Xopt))
return Xopt

0 comments on commit 7a71680

Please sign in to comment.