google-deepmind / ferminet

An implementation of the Fermionic Neural Network for ab-initio electronic structure calculations
Apache License 2.0
740 stars 129 forks source link

ferminet.network do not have fermi_net function #77

Closed FXTY closed 2 months ago

FXTY commented 2 months ago

When I want to run the program, there is an error that AttributeError: module 'ferminet.networks' has no attribute 'fermi_net'. what should I do to solve this problem. The program I run is

import numpy as np
import jax
from functools import partial
from ferminet import networks, train

with open('params.npz', 'rb') as f:
  params = dict(np.load(f, allow_pickle=True))
  params = params['arr_0'].tolist()

with open('walkers.npy', 'rb') as f:
  data = np.load(f)

with open('geometry.npz', 'rb') as f:
  geometry = dict(np.load(f, allow_pickle=True))

signed_network = partial(networks.fermi_net, envelope_type='isotropic', full_det=False, **geometry)
# networks.fermi_net gives the sign/log of the wavefunction. We only care about the latter.
network = lambda p, x: signed_network(p, x)[1]
batch_network = jax.vmap(network, (None, 0), 0)
loss = train.make_loss(network, batch_network, geometry['atoms'], geometry['charges'], clip_local_energy=5.0)

print(loss(params, data)[0])  # For neon, should give -128.94165
jsspencer commented 2 months ago

Sorry, those instructions are now out of date following (extensive) refactoring. You can either use an earlier version of the code, which does have that interface, or train a new model. I suspect that the pretrained checkpoints linked in the documentation are not compatible with the current code.