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

Consistent naming between dy and forces #121

Merged
merged 6 commits into from Oct 11, 2022
Merged

Consistent naming between dy and forces #121

merged 6 commits into from Oct 11, 2022

Conversation

PhilippThoelke
Copy link
Collaborator

@PhilippThoelke PhilippThoelke commented Aug 30, 2022

This PR renames y to energy and dy to forces in places where we mean forces and not gradients. PyTorch-Geometric Data objects are now constructed as Data(energy=<energy>, ...) or Data(energy=<energy>, forces=<forces>, ...). This should not change any behavior but just concerns naming conventions. Linked to #116

@peastman
Copy link
Collaborator

Do you also want to rename y to energy? It seems like it would be more consistent to either name both as abstract variables (y and dy, in which case the latter would be the gradient of the former), or else name both as physical quantities (energy and forces, in which case it's the negative gradient). Mixing them can be confusing.

@PhilippThoelke
Copy link
Collaborator Author

Initially I thought torch geometric was requiring setting y when constructing a Data object but now I'm not sure anymore. I agree that energy and forces makes more sense than y and forces. I'll rename y as well if torch geometric doesn't prohibit that.

@stefdoerr
Copy link
Collaborator

I'm a bit divided here. We use torchmd-net also for pKa prediction and in the future maybe also for charge prediction. This will make it more confusing, will it not?

@PhilippThoelke
Copy link
Collaborator Author

Do you mean renaming both y and dy are confusing or would you want dy to be forces and y to stay as it is?

@stefdoerr
Copy link
Collaborator

I think renaming them both is confusing. I think they should be named energy/forces only internally at the datasets level (and they should return y/dy) and not at the train/script level where you could replace the datasets with other type of data. The problem here being that we don't train on dy but on minus_dy which makes it ugly.

@peastman
Copy link
Collaborator

If the models are intended to be used for predicting things other than energy, I agree that y and dy is a better choice, and dy should be the positive gradient.

@PhilippThoelke
Copy link
Collaborator Author

Changing the model to return the positive gradient now would silently break a lot of applications, I don't think that's a good idea. I'd be okay with calling it y and neg_dy or something like that to make it clear.

@raimis
Copy link
Collaborator

raimis commented Sep 1, 2022

Regarding the variable names, my preference is d/dy, but energy/forces is fine. Could they be made consistent in models.model.TorchMD_Net too.

@raimis
Copy link
Collaborator

raimis commented Sep 1, 2022

Another options: models.model.TorchMD_Net.forward does not only the computation of y (the forward pass), but also the computation of dy (the backward pass). We can factor out the gradient computation into a separate function/method. As a side effect, the sign of dy could be changed without breaking the others code silently.

@PhilippThoelke PhilippThoelke linked an issue Oct 10, 2022 that may be closed by this pull request
@PhilippThoelke
Copy link
Collaborator Author

I updated (hopefully) all places to consistently use y as the label/prediction and neg_dy as the negative derivative of the label/prediction.

@PhilippThoelke PhilippThoelke requested review from raimis, stefdoerr and giadefa and removed request for raimis and giadefa October 10, 2022 18:08
@giadefa
Copy link
Contributor

giadefa commented Oct 11, 2022 via email

Copy link
Collaborator

@raimis raimis left a comment

Choose a reason for hiding this comment

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

Looks ugly, but at least consistent.

@PhilippThoelke PhilippThoelke merged commit d091c8f into main Oct 11, 2022
@PhilippThoelke PhilippThoelke deleted the naming branch October 11, 2022 14:52
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.

Inconsistency between gradients and forces
5 participants