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 dtype in self_energies #347

Merged
merged 5 commits into from
Oct 24, 2019
Merged

Fix dtype in self_energies #347

merged 5 commits into from
Oct 24, 2019

Conversation

farhadrgh
Copy link
Member

@farhadrgh farhadrgh commented Oct 23, 2019

I wonder why the test hadn't failed before!

@@ -192,7 +192,7 @@ def sae(self, species):
intercept = self.self_energies[-1]

self_energies = self.self_energies[species]
self_energies[species == torch.tensor(-1, device=species.device)] = torch.tensor(0, device=species.device, dtype=self_energies.dtype)
self_energies[species == torch.tensor(-1, device=species.device)] = torch.tensor(0, device=species.device, dtype=torch.double)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about removing the dtype and replace the 0 with 0.0?

Copy link
Member Author

@farhadrgh farhadrgh Oct 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zasdfgbnm self_energies.dtype should be double, but float32 is enforced in comp6.py, is there any particular reason for that?

see in: https://github.com/aiqm/torchani/pull/347/checks?check_run_id=273594990#step:9:25

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farhadrgh No, there is no reason. I guess it is just randomly picking a dtype.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farhadrgh Also, there are some trick here, energy shifter is a module, so if you put it inside
model = torch.nn.Sequential(aev_computer, nn, energy_shifter) and then model.to(torch.float) it will also be cast into float. I don't have a good idea on how to solve that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the dtype in comp6.py (6930879), this will let the tests pass peacefully

@zasdfgbnm zasdfgbnm merged commit 41aa0f4 into master Oct 24, 2019
@zasdfgbnm zasdfgbnm deleted the farhadrgh-patch-1 branch October 24, 2019 17:08
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