Skip to content

Commit

Permalink
Fix the dimension in self_energies for dataset containing only one el…
Browse files Browse the repository at this point in the history
…ements (#302)

* Update utils.py

if I train molecule like Oxygen which contains only one element, the self.self_energies is a scalar and will make the operation self_energies = self.self_energies[species] crash. Besides, the species of Oxygen is [[3,3]] and is over the boundary of the energy list, so need to minus the minimum.

* Update utils.py
  • Loading branch information
tamaswells authored and farhadrgh committed Sep 8, 2019
1 parent 379d2b3 commit 9715749
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchani/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def sae_from_dataset(self, atomic_properties, properties):
X = torch.cat((X, torch.ones(X.shape[0], 1).to(torch.double)), dim=-1)
y = energies.unsqueeze(dim=-1)
coeff_, _, _, _ = np.linalg.lstsq(X, y, rcond=None)
return coeff_.squeeze()
return coeff_.squeeze(-1)

def sae(self, species):
"""Compute self energies for molecules.
Expand Down

0 comments on commit 9715749

Please sign in to comment.