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

error with batch prediction in spk.model.NeuralNetworkPotential #26

Open
blindpikachu opened this issue Jan 31, 2023 · 0 comments
Open

Comments

@blindpikachu
Copy link

When 'trn.AddOffsets(MD17.energy, add_mean=True, add_atomrefs=False)' is used in 'spk.model.NeuralNetworkPotential', the batch predictions only has one value in 'energy'. If this term is not used, it works correctly.

#example script from MD17 in tutorials
from ase import Atoms

load model

model_path = os.path.join(forcetut, "best_inference_model")
best_model = torch.load(model_path).to('cpu')

set up converter

converter = spk.interfaces.AtomsConverter(
neighbor_list=trn.ASENeighborList(cutoff=5.0), dtype=torch.float32
)

res = {}
for i in range(256):
# create atoms object from dataset
structure = ethanol_data.test_dataset[i]
atoms = Atoms(
numbers=structure[spk.properties.Z], positions=structure[spk.properties.R]
)
inputs = converter(atoms)
for list in inputs:
if list in res:
res[list] = torch.cat([res[list],inputs[list]], 0)
else:
res[list] = inputs[list]
res['_pbc'] = res['_pbc'].reshape(-1) #need to reshape too?

print(res['energy'])

res["energy"] = torch.rand(256)

print(res['energy'].shape)

convert atoms to SchNetPack inputs and perform prediction

results = best_model(res)

print(results)

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

No branches or pull requests

1 participant