Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non convergence in example of usage #13

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

Mboky
Copy link
Contributor

@Mboky Mboky commented Dec 5, 2023

Hi,

The current example of usage does not converge in the amount of iterations specified

import netket as nk
import netket_fidelity as nkf

# Create the Hilbert space and the variational states |ψ⟩ and |ϕ⟩
hi = nk.hilbert.Spin(0.5, 4)
sampler = nk.sampler.MetropolisLocal(hilbert=hi, n_chains_per_rank=16)
model = nk.models.RBM(alpha=1, param_dtype=complex, use_visible_bias=False)
phi = nk.vqs.MCState(sampler=sampler, model=model, n_samples=100)
psi = nk.vqs.MCState(sampler=sampler, model=model, n_samples=100)

# Transformation U
U = nkf.operator.Hadamard(hi, 0)

# Create the driver
optimizer = nk.optimizer.Sgd(learning_rate=0.01)
te =  nkf.driver.InfidelityOptimizer(phi, optimizer, U=U, U_dagger=U, variational_state=psi, is_unitary=True, cv_coeff=-1/2)

# Run the driver
te.run(n_iter=100)

This keeps yielding an infidelity around 0.5. Either adding more iterations or changing to the Adam optimizer fixes this.
With Adam and the same number of iterations, infidelity is consistently smaller than 0.001

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0a19a8b) 77.13% compared to head (009e4ee) 77.23%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
+ Coverage   77.13%   77.23%   +0.10%     
==========================================
  Files          21       21              
  Lines         678      681       +3     
  Branches      117      117              
==========================================
+ Hits          523      526       +3     
  Misses        129      129              
  Partials       26       26              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alleSini99
Copy link
Collaborator

alleSini99 commented Dec 5, 2023

Thanks!

@alleSini99 alleSini99 merged commit 5f1bad5 into netket:main Dec 5, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants