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

PR on nnlda layer #3237

Merged
merged 22 commits into from
Mar 28, 2023
Merged

PR on nnlda layer #3237

merged 22 commits into from
Mar 28, 2023

Conversation

advikavs
Copy link
Contributor

@advikavs advikavs commented Feb 10, 2023

Description

PR on nnlda layer

Copy link
Member

@rbharath rbharath left a comment

Choose a reason for hiding this comment

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

Good start! Made a couple of preliminary comments

deepchem/models/dft/nnxc.py Outdated Show resolved Hide resolved
Neural network for xc functional
ninpmode: int
The mode to decide the transformation of the density to NN input.
outmultmode: int
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a usage example and a returns section to the docstring?

self,
xcstr: str,
nnmodel: torch.nn.Module,
*,
Copy link
Member

Choose a reason for hiding this comment

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

  • arguments are a bad pattern imo. We shouldn't use them in the deepchem codebase.

super().__init__()
# What is type of xc here?
self.xc = get_xc(xcstr)
print(type(self.xc))
Copy link
Member

Choose a reason for hiding this comment

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

Print statements should be removed before merge

deepchem/models/dft/nnxc.py Show resolved Hide resolved
Copy link
Member

@rbharath rbharath left a comment

Choose a reason for hiding this comment

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

Getting closer! Main issue is we need a lot more documentation to explain what these layers do.

deepchem/models/dft/nnxc.py Outdated Show resolved Hide resolved
deepchem/models/dft/nnxc.py Show resolved Hide resolved
deepchem/models/dft/nnxc.py Outdated Show resolved Hide resolved

class NNLDA(BaseNNXC):
"""
Neural network xc functional of LDA (only receives the density as input)
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a usage example? There should be an explanation of what LDA is as a DFT method, along with a suitable reference. Aim for at least a few paragraphs of discussion

nnmodel: torch.nn.Module
Neural network for xc functional
ninpmode: int
The mode to decide the transformation of the density to NN input.
Copy link
Member

Choose a reason for hiding this comment

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

What are the valid values? What does each value mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently we only support one mode, so I have removed it. Will add it back in the next iterations.

Neural network for xc functional
ninpmode: int
The mode to decide the transformation of the density to NN input.
outmultmode: int
Copy link
Member

Choose a reason for hiding this comment

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

What are the valid values for the output? What does each value mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently we only support one mode, so I have removed it. Will add it back in the next iterations.

deepchem/models/dft/nnxc.py Show resolved Hide resolved
deepchem/models/dft/nnxc.py Show resolved Hide resolved
try:
from dqc.xc.base_xc import BaseXC
from dqc.utils.datastruct import ValGrad, SpinParam
from dqc.api.getxc import get_xc
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a utility function. Can you copy this in directly from dqc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we trying to do that in this iteration? If so, I'm not so sure, but I will look into it.

@advikavs advikavs changed the title Initial PR on nnlda layer PR on nnlda layer Mar 9, 2023
Copy link
Member

@rbharath rbharath left a comment

Choose a reason for hiding this comment

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

Almost there. Just a couple more comment improvements to address and we should be ready to merge

deepchem/models/dft/nnxc.py Show resolved Hide resolved
deepchem/models/dft/nnxc.py Show resolved Hide resolved
Copy link
Member

@rbharath rbharath left a comment

Choose a reason for hiding this comment

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

Almost ready to go. Have a few more requests for documentation improvement here


class BaseNNXC(torch.nn.Module):
"""
Base class for the NNLDA and HybridXC classes.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add more detail on when we would want to use this base class and what capabilities it provides? A good paragraph of explanation would be my rule of thumb

deepchem/models/dft/nnxc.py Show resolved Hide resolved

Returns
-------
res
Copy link
Member

Choose a reason for hiding this comment

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

What is the shape of res?

class HybridXC(BaseNNXC):
"""
The HybridXC module computes XC energy by summing XC energy computed
from libxc and the trainable neural network with tunable weights.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a brief explanation of what libxc is?

Copy link
Member

@rbharath rbharath left a comment

Choose a reason for hiding this comment

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

LGTM, feel free to merge in once CI is clear

@advikavs
Copy link
Contributor Author

LGTM, feel free to merge in once CI is clear

The CI is fine. But I don't have merge access, it is blocked. Thanks

Copy link
Member

@rbharath rbharath left a comment

Choose a reason for hiding this comment

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

LGTM

@rbharath rbharath merged commit aed9bc5 into deepchem:master Mar 28, 2023
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.

None yet

2 participants