-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add zinc protein #3
Conversation
Support virial forward run on gpu with cpu kernel
Deepmd in Paddle for example, just 'water_se_a' model
…a_cpu fix error in cpu mode
…load support jist save load
deepmd/descriptor/se_a_mask.py
Outdated
@@ -115,6 +117,8 @@ def __init__( | |||
precision: str = "default", | |||
uniform_seed: bool = False, | |||
) -> None: | |||
paddle.nn.Layer.__init__(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 把上面的
@Descriptor.register("se_a_mask")
装饰器去掉 - 使用
super().__init__()
deepmd/descriptor/se_a_mask.py
Outdated
self.place_holders[ii] = tf.placeholder( | ||
GLOBAL_NP_FLOAT_PRECISION, [None, None], name=name_pfx + "t_" + ii | ||
# self.nei_type = tf.constant(nei_type, dtype=tf.int32) | ||
self.nei_type = paddle.to_tensor(nei_type, dtype="int32") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.register_buffer("nei_type", paddle.to_tensor(nei_type, dtype="int32")),注册为buffer代替to_tensor
deepmd/descriptor/se_a_mask.py
Outdated
# avg_zero = np.zeros([self.ntypes, self.ndescrpt]).astype( | ||
# GLOBAL_NP_FLOAT_PRECISION | ||
# ) | ||
# std_ones = np.ones([self.ntypes, self.ndescrpt]).astype( | ||
# GLOBAL_NP_FLOAT_PRECISION | ||
# ) | ||
# sub_graph = tf.Graph() | ||
# with sub_graph.as_default(): | ||
# name_pfx = "d_sea_mask_" | ||
# for ii in ["coord", "box"]: | ||
# self.place_holders[ii] = tf.placeholder( | ||
# GLOBAL_NP_FLOAT_PRECISION, [None, None], name=name_pfx + "t_" + ii | ||
# ) | ||
# self.place_holders["type"] = tf.placeholder( | ||
# tf.int32, [None, None], name=name_pfx + "t_type" | ||
# ) | ||
# self.place_holders["mask"] = tf.placeholder( | ||
# tf.int32, [None, None], name=name_pfx + "t_aparam" | ||
# ) # named aparam for inference compatibility in c++ interface. | ||
|
||
# self.place_holders["natoms_vec"] = tf.placeholder( | ||
# tf.int32, [self.ntypes + 2], name=name_pfx + "t_natoms" | ||
# ) # Not used in se_a_mask. For compatibility with c++ interface. | ||
# self.place_holders["default_mesh"] = tf.placeholder( | ||
# tf.int32, [None], name=name_pfx + "t_mesh" | ||
# ) # Not used in se_a_mask. For compatibility with c++ interface. | ||
|
||
# self.stat_descrpt, descrpt_deriv, rij, nlist = op_module.descrpt_se_a_mask( | ||
# self.place_holders["coord"], | ||
# self.place_holders["type"], | ||
# self.place_holders["mask"], | ||
# self.place_holders["box"], | ||
# self.place_holders["natoms_vec"], | ||
# self.place_holders["default_mesh"], | ||
# ) | ||
# self.sub_sess = tf.Session(graph=sub_graph, config=default_tf_session_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些tf注释代码可以删除
deepmd/train/trainer.py
Outdated
@@ -126,8 +126,12 @@ def _init_param(self, jdata): | |||
descrpt_param["multi_task"] = True | |||
if descrpt_param["type"] in ["se_e2_a", "se_a", "se_e2_r", "se_r", "hybrid"]: | |||
descrpt_param["spin"] = self.spin | |||
descrpt_param.pop("type") | |||
self.descrpt = deepmd.descriptor.se_a.DescrptSeA(**descrpt_param) | |||
if descrpt_param["type"]=="se_a_mask": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
==
两侧要有空格
self.mask = paddle.to_tensor(self.mask, place="cpu") | ||
box_ = paddle.to_tensor(box_, place="cpu") | ||
natoms = paddle.to_tensor(natoms, place="cpu") | ||
mesh = paddle.to_tensor(mesh, place="cpu") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
357~258之间空一行
} | ||
|
||
|
||
void DescrptSeAMaskCPUKernel(int n_descrpt, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
将DescrptSeAMaskCPUKernel
从普通函数改造成模板函数,可参考其他文件,否则浮点类型会被固定为double
descrpt[kk*total_atom_num * total_atom_num * n_descrpt+ ii * total_atom_num * 4 + jj] = 0.; | ||
} | ||
for (int jj = 0; jj < natoms * 4 * 3; ++jj) { | ||
descrpt_deriv[kk*total_atom_num * total_atom_num * n_descrpt * 3+ ii * total_atom_num * 4 * 3 + jj] = 0.; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
运算符号两侧加上空格
// int nloc = total_atom_num; | ||
// int ndescrpt = nloc > 0 ? nframes * nloc * 3 / net_deriv.shape()[1] : 0; | ||
// int ndescrpt = nloc * 4; | ||
// int nnei = total_atom_num; | ||
// int nnei = nloc > 0 ? nlist_tensor.shape()[1] / nloc : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以删除
// int ndescrpt = nloc > 0 ? net_deriv_tensor.shape()[1] / nloc : 0; | ||
// int nnei = total_atom_num; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为什么不能用注释里的代码呢
.Inputs({paddle::Grad("force"), "net_deriv", "in_deriv", "mask", "nlist"}) | ||
.Attrs({"total_atom_num: int"}) | ||
.Outputs({paddle::Grad("net_deriv")}) | ||
.SetKernelFn(PD_KERNEL(ProdForceSeAMaskBackward)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缩进四个空格
No description provided.