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

raise warning before training if sel is not enough #914

Merged
merged 1 commit into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions deepmd/entrypoints/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,22 @@ def wrap_up_4(xx):


def update_one_sel(jdata, descriptor):
rcut = descriptor['rcut']
tmp_sel = get_sel(jdata, rcut)
if parse_auto_sel(descriptor['sel']) :
ratio = parse_auto_sel_ratio(descriptor['sel'])
rcut = descriptor['rcut']
tmp_sel = get_sel(jdata, rcut)
descriptor['sel'] = [int(wrap_up_4(ii * ratio)) for ii in tmp_sel]
else:
# sel is set by user
for ii, (tt, dd) in enumerate(zip(tmp_sel, descriptor['sel'])):
if dd and tt > dd:
# we may skip warning for sel=0, where the user is likely
# to exclude such type in the descriptor
log.warning(
"sel of type %d is not enough! The expected value is "
"not less than %d, but you set it to %d. The accuracy"
" of your model may get worse." %(ii, tt, dd)
)
return descriptor


Expand Down
7 changes: 7 additions & 0 deletions deepmd/utils/neighbor_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ def get_stat(self,
log.warning("Atoms with no neighbors found in %s. Please make sure it's what you expected."%jj)

if dt < self.min_nbor_dist:
if math.isclose(dt, 0., rel_tol=1e-6):
# it's unexpected that the distance between two atoms is zero
# zero distance will cause nan (#874)
raise RuntimeError(
"Some atoms in %s are overlapping. Please check your"
" training data to remove duplicated atoms." % jj
)
self.min_nbor_dist = dt
for ww in range(self.ntypes):
var = np.max(mn[:, ww])
Expand Down