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

set input name to input.json #68

Merged
merged 7 commits into from
Aug 11, 2019
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
41 changes: 10 additions & 31 deletions dpgen/generator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
train_name = '00.train'
train_task_fmt = '%03d'
train_tmpl_path = os.path.join(template_name, train_name)
default_train_input_file = 'input.json'
data_system_fmt = '%03d'
model_devi_name = '01.model_devi'
model_devi_task_fmt = data_system_fmt + '.%06d'
Expand Down Expand Up @@ -170,7 +171,8 @@ def make_train (iter_index,
jdata,
mdata) :
# load json param
train_param = jdata['train_param']
# train_param = jdata['train_param']
train_input_file = default_train_input_file
numb_models = jdata['numb_models']
init_data_prefix = jdata['init_data_prefix']
init_data_prefix = os.path.abspath(init_data_prefix)
Expand Down Expand Up @@ -277,7 +279,7 @@ def make_train (iter_index,
jinput['model']['descriptor']['seed'] = random.randrange(sys.maxsize) % (2**32)
jinput['model']['fitting_net']['seed'] = random.randrange(sys.maxsize) % (2**32)
jinput['training']['seed'] = random.randrange(sys.maxsize) % (2**32)
with open(os.path.join(task_path, train_param), 'w') as outfile:
with open(os.path.join(task_path, train_input_file), 'w') as outfile:
json.dump(jinput, outfile, indent = 4)

# link old models
Expand Down Expand Up @@ -315,7 +317,8 @@ def run_train (iter_index,
ssh_sess) :
# load json param
numb_models = jdata['numb_models']
train_param = jdata['train_param']
# train_param = jdata['train_param']
train_input_file = default_train_input_file
try:
mdata["deepmd_version"]
except:
Expand Down Expand Up @@ -345,12 +348,12 @@ def run_train (iter_index,
if LooseVersion(mdata["deepmd_version"]) < LooseVersion('1'):
# 0.x
command = os.path.join(deepmd_path, 'bin/dp_train')
command += ' %s && ' % train_param
command += ' %s && ' % train_input_file
command += os.path.join(deepmd_path, 'bin/dp_frz')
else:
# 1.x
command = '%s -m deepmd train' % python_path
command += ' %s && ' % train_param
command += ' %s && ' % train_input_file
command += '%s -m deepmd freeze' % python_path

#_tasks = [os.path.basename(ii) for ii in all_task]
Expand All @@ -364,7 +367,7 @@ def run_train (iter_index,
else:
run_tasks.append(ii)

forward_files = [train_param]
forward_files = [train_input_file]
backward_files = ['frozen_model.pb', 'lcurve.out']
init_data_sys_ = jdata['init_data_sys']
init_data_sys = []
Expand Down Expand Up @@ -474,16 +477,6 @@ def post_train (iter_index,
mdata) :
# load json param
numb_models = jdata['numb_models']
try:
mdata["deepmd_version"]
except:
mdata = set_version(mdata)
if LooseVersion(mdata["deepmd_version"]) < LooseVersion('1'):
# 0.x
deepmd_path = mdata['deepmd_path']
else:
# 1.x
python_path = mdata['python_path']
# paths
iter_name = make_iter_name(iter_index)
work_path = os.path.join(iter_name, train_name)
Expand All @@ -492,27 +485,13 @@ def post_train (iter_index,
if os.path.isfile(copy_flag) :
log_task('copied model, do not post train')
return
all_task = []
for ii in range(numb_models) :
task_path = os.path.join(work_path, train_task_fmt % ii)
all_task.append(task_path)
if LooseVersion(mdata["deepmd_version"]) < LooseVersion('1'):
# 0.x
command = os.path.join(deepmd_path, 'bin/dp_frz')
else:
# 1.x
command = python_path + ' -m deepmd freeze'
command = cmd_append_log(command, 'freeze.log')
command = 'CUDA_VISIBLE_DEVICES="" ' + command
# frz models
# exec_hosts(MachineLocal, command, 1, all_task, None)
# symlink models
for ii in range(numb_models) :
task_file = os.path.join(train_task_fmt % ii, 'frozen_model.pb')
ofile = os.path.join(work_path, 'graph.%03d.pb' % ii)
if os.path.isfile(ofile) :
os.remove(ofile)
os.symlink(task_file, ofile)
os.symlink(task_file, ofile)

def _get_param_alias(jdata,
names) :
Expand Down
1 change: 0 additions & 1 deletion examples/generator/param_CH4.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

"_comment": " 00.train ",
"numb_models": 4,
"train_param": "input.json",
"default_training_param" : {
"_comment": " model parameters",
"use_smooth": true,
Expand Down
1 change: 0 additions & 1 deletion examples/generator/param_al_all_gpu.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@

"_comment": " 00.train ",
"numb_models": 4,
"train_param": "input.json",
"default_training_param" : {
"_comment": " model parameters",
"use_smooth": true,
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
with open(readme_file) as f:
readme = f.read()

install_requires=['numpy>=1.14.3,<1.17', 'dpdata>=0.1.2', 'pymatgen', 'ase', 'monty', 'paramiko', 'custodian']
install_requires=['numpy>=1.14.3,<1.17', 'dpdata>=0.1.2', 'pymatgen', 'ase', 'monty>2.0.0', 'paramiko', 'custodian']

setuptools.setup(
name=NAME,
version_format='{tag}.dev{commitcount}+{gitsha}',
version="0.1.0",
setup_requires=['setuptools-git-version'],
author="Han Wang",
author_email="wang_han@iapcm.ac.cn",
description="Manipulating DeePMD-kit, VASP and LAMMPS data formats",
description="DPGen: The deep potential generator",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/deepmodeling/dpgen",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/data/test_gen_surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test(self):
poscars=glob.glob("surf.al.fcc.01x01x01/00.place_ele/surf*/sys*/POSCAR")
for poscar in poscars:
surf=poscar.split('/')[-3]
st1=Structure.from_file(surf+'.vasp')
st1=Structure.from_file(surf+'.POSCAR')
st2=Structure.from_file(poscar)
self.assertEqual(st1,st2)

Expand Down