Skip to content

Commit 0768cea

Browse files
authored
Merge pull request #96 from amcadmus/devel
data stat and scale fparam , cleanup the interface of descriptor's data stat
2 parents 6b9c29e + f9dd3a5 commit 0768cea

14 files changed

+166
-101
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ matrix:
3131
- CC=gcc-4.8
3232
- CXX=g++-4.8
3333
- TENSORFLOW_VERSION=1.14
34+
- python: 3.6
35+
env:
36+
- CC=gcc-5
37+
- CXX=g++-5
38+
- TENSORFLOW_VERSION=1.14
39+
- python: 3.6
40+
env:
41+
- CC=gcc-8
42+
- CXX=g++-8
43+
- TENSORFLOW_VERSION=1.14
3444
- python: 3.7
3545
env:
3646
- CC=gcc-5

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,7 @@ If other unexpected problems occur, you're welcome to contact us for help.
533533

534534
When the version of DeePMD-kit used to training model is different from the that of DeePMD-kit running MDs, one has the problem of model compatability.
535535

536-
DeePMD-kit guarantees that the codes with the same major and minor revisions are compatible. That is to say v0.12.5 is compatible to v0.12.0, but is not compatible to v0.11.0. When way of fixing it is to restart the training with the new revisions and a slightly increased `stop_batch`, say 1,000,000 to 1,001,000 if the `save_freq` was set to 1,000. Typically one runs
537-
```bash
538-
dp train --restart model.ckpt revised_input.json
539-
```
540-
and freeze the new model.
536+
DeePMD-kit guarantees that the codes with the same major and minor revisions are compatible. That is to say v0.12.5 is compatible to v0.12.0, but is not compatible to v0.11.0 nor v1.0.0.
541537

542538
## Installation: inadequate versions of gcc/g++
543539
Sometimes you may use a gcc/g++ of version <4.9. If you have a gcc/g++ of version > 4.9, say, 7.2.0, you may choose to use it by doing

source/tests/test_model_loc_frame.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ def test_model(self):
4242
fitting = EnerFitting(jdata['model']['fitting_net'], descrpt)
4343
model = Model(jdata['model'], descrpt, fitting)
4444

45-
model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
45+
# model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
46+
input_data = {'coord' : [test_data['coord']],
47+
'box': [test_data['box']],
48+
'type': [test_data['type']],
49+
'natoms_vec' : [test_data['natoms_vec']],
50+
'default_mesh' : [test_data['default_mesh']]
51+
}
52+
model._compute_dstats(input_data)
4653
model.bias_atom_e = data.compute_energy_shift()
4754

4855
t_prop_c = tf.placeholder(tf.float32, [5], name='t_prop_c')

source/tests/test_model_se_a.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ def test_model(self):
4242
fitting = EnerFitting(jdata['model']['fitting_net'], descrpt)
4343
model = Model(jdata['model'], descrpt, fitting)
4444

45-
model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
45+
# model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
46+
input_data = {'coord' : [test_data['coord']],
47+
'box': [test_data['box']],
48+
'type': [test_data['type']],
49+
'natoms_vec' : [test_data['natoms_vec']],
50+
'default_mesh' : [test_data['default_mesh']]
51+
}
52+
model._compute_dstats(input_data)
4653
model.bias_atom_e = data.compute_energy_shift()
4754

4855
t_prop_c = tf.placeholder(tf.float32, [5], name='t_prop_c')

source/tests/test_model_se_a_fparam.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ def test_model(self):
4141
fitting = EnerFitting(jdata['model']['fitting_net'], descrpt)
4242
model = Model(jdata['model'], descrpt, fitting)
4343

44-
model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
44+
# model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
45+
input_data = {'coord' : [test_data['coord']],
46+
'box': [test_data['box']],
47+
'type': [test_data['type']],
48+
'natoms_vec' : [test_data['natoms_vec']],
49+
'default_mesh' : [test_data['default_mesh']],
50+
'fparam': [test_data['fparam']],
51+
}
52+
model._compute_dstats(input_data)
4553
model.bias_atom_e = data.compute_energy_shift()
4654

4755
t_prop_c = tf.placeholder(tf.float32, [5], name='t_prop_c')
@@ -94,9 +102,9 @@ def test_model(self):
94102
e = e.reshape([-1])
95103
f = f.reshape([-1])
96104
v = v.reshape([-1])
97-
refe = [6.135136929183754972e+01]
98-
reff = [7.761477777656561328e-02,9.383013575207051205e-02,3.776776376267230399e-03,1.428268971463224069e-01,1.143858253900619654e-01,-1.318441687719179231e-02,-7.271897092708884403e-02,6.494907553857684479e-02,5.355599592111062821e-04,5.840910251709752199e-02,-1.599042555763417750e-01,-5.067165555590445389e-03,-2.546246315216804113e-01,3.073296814647456451e-02,1.505994759166155023e-02,4.849282500878367153e-02,-1.439937492508420736e-01,-1.120701494357654411e-03]
99-
refv = [-6.054303146013112480e-01,1.097859194719944115e-01,1.977605183964963390e-02,1.097859194719943976e-01,-3.306167096812382966e-01,-5.978855662865613894e-03,1.977605183964964083e-02,-5.978855662865616497e-03,-1.196331922996723236e-03]
105+
refe = [61.35473702079649]
106+
reff = [7.789591210641927388e-02,9.411176646369459609e-02,3.785806413688173194e-03,1.430830954178063386e-01,1.146964190520970150e-01,-1.320340288927138173e-02,-7.308720494747594776e-02,6.508269338140809657e-02,5.398739145542804643e-04,5.863268336973800898e-02,-1.603409523950408699e-01,-5.083084610994957619e-03,-2.551569799443983988e-01,3.087934885732580501e-02,1.508590526622844222e-02,4.863249399791078065e-02,-1.444292753594846324e-01,-1.125098094204559241e-03]
107+
refv = [-6.069498397488943819e-01,1.101778888191114192e-01,1.981907430646132409e-02,1.101778888191114608e-01,-3.315612988100872793e-01,-5.999739184898976799e-03,1.981907430646132756e-02,-5.999739184898974197e-03,-1.198656608172396325e-03]
100108
refe = np.reshape(refe, [-1])
101109
reff = np.reshape(reff, [-1])
102110
refv = np.reshape(refv, [-1])

source/tests/test_model_se_a_srtab.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ def test_model(self):
5151
fitting = EnerFitting(jdata['model']['fitting_net'], descrpt)
5252
model = Model(jdata['model'], descrpt, fitting)
5353

54-
model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
54+
# model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
55+
input_data = {'coord' : [test_data['coord']],
56+
'box': [test_data['box']],
57+
'type': [test_data['type']],
58+
'natoms_vec' : [test_data['natoms_vec']],
59+
'default_mesh' : [test_data['default_mesh']]
60+
}
61+
model._compute_dstats(input_data)
5562
model.bias_atom_e = data.compute_energy_shift()
5663

5764
t_prop_c = tf.placeholder(tf.float32, [5], name='t_prop_c')

source/tests/test_model_se_r.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ def test_model(self):
4141
fitting = EnerFitting(jdata['model']['fitting_net'], descrpt)
4242
model = Model(jdata['model'], descrpt, fitting)
4343

44-
model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
44+
# model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
45+
input_data = {'coord' : [test_data['coord']],
46+
'box': [test_data['box']],
47+
'type': [test_data['type']],
48+
'natoms_vec' : [test_data['natoms_vec']],
49+
'default_mesh' : [test_data['default_mesh']]
50+
}
51+
model._compute_dstats(input_data)
4552
model.bias_atom_e = data.compute_energy_shift()
4653

4754
t_prop_c = tf.placeholder(tf.float32, [5], name='t_prop_c')

source/tests/test_polar_se_a.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ def test_model(self):
4141
fitting = PolarFittingSeA(jdata['model']['fitting_net'], descrpt)
4242
model = PolarModel(jdata['model'], descrpt, fitting)
4343

44-
model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
44+
# model._compute_dstats([test_data['coord']], [test_data['box']], [test_data['type']], [test_data['natoms_vec']], [test_data['default_mesh']])
45+
input_data = {'coord' : [test_data['coord']],
46+
'box': [test_data['box']],
47+
'type': [test_data['type']],
48+
'natoms_vec' : [test_data['natoms_vec']],
49+
'default_mesh' : [test_data['default_mesh']],
50+
'fparam': [test_data['fparam']],
51+
}
52+
model._compute_dstats(input_data)
4553

4654
t_prop_c = tf.placeholder(tf.float32, [5], name='t_prop_c')
4755
t_energy = tf.placeholder(global_ener_float_precision, [None], name='t_energy')

source/train/DescrptLocFrame.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def compute_dstats (self,
5454
data_box,
5555
data_atype,
5656
natoms_vec,
57-
mesh,
58-
reuse = None) :
57+
mesh) :
5958
all_davg = []
6059
all_dstd = []
6160
if True:
@@ -64,7 +63,7 @@ def compute_dstats (self,
6463
sumv2 = []
6564
for cc,bb,tt,nn,mm in zip(data_coord,data_box,data_atype,natoms_vec,mesh) :
6665
sysv,sysv2,sysn \
67-
= self._compute_dstats_sys_nonsmth(cc,bb,tt,nn,mm,reuse)
66+
= self._compute_dstats_sys_nonsmth(cc,bb,tt,nn,mm)
6867
sumv.append(sysv)
6968
sumn.append(sysn)
7069
sumv2.append(sysv2)
@@ -167,8 +166,7 @@ def _compute_dstats_sys_nonsmth (self,
167166
data_box,
168167
data_atype,
169168
natoms_vec,
170-
mesh,
171-
reuse = None) :
169+
mesh) :
172170
avg_zero = np.zeros([self.ntypes,self.ndescrpt]).astype(global_np_float_precision)
173171
std_ones = np.ones ([self.ntypes,self.ndescrpt]).astype(global_np_float_precision)
174172
sub_graph = tf.Graph()

source/train/DescrptSeA.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def compute_dstats (self,
6767
data_box,
6868
data_atype,
6969
natoms_vec,
70-
mesh,
71-
reuse = None) :
70+
mesh) :
7271
all_davg = []
7372
all_dstd = []
7473
if True:
@@ -79,7 +78,7 @@ def compute_dstats (self,
7978
suma2 = []
8079
for cc,bb,tt,nn,mm in zip(data_coord,data_box,data_atype,natoms_vec,mesh) :
8180
sysr,sysr2,sysa,sysa2,sysn \
82-
= self._compute_dstats_sys_smth(cc,bb,tt,nn,mm,reuse)
81+
= self._compute_dstats_sys_smth(cc,bb,tt,nn,mm)
8382
sumr.append(sysr)
8483
suma.append(sysa)
8584
sumn.append(sysn)
@@ -134,12 +133,12 @@ def build (self,
134133
davg.shape,
135134
dtype = global_tf_float_precision,
136135
trainable = False,
137-
initializer = tf.constant_initializer(davg, dtype = global_tf_float_precision))
136+
initializer = tf.constant_initializer(davg))
138137
self.t_std = tf.get_variable('t_std',
139138
dstd.shape,
140139
dtype = global_tf_float_precision,
141140
trainable = False,
142-
initializer = tf.constant_initializer(dstd, dtype = global_tf_float_precision))
141+
initializer = tf.constant_initializer(dstd))
143142

144143
coord = tf.reshape (coord_, [-1, natoms[1] * 3])
145144
box = tf.reshape (box_, [-1, 9])
@@ -222,8 +221,7 @@ def _compute_dstats_sys_smth (self,
222221
data_box,
223222
data_atype,
224223
natoms_vec,
225-
mesh,
226-
reuse = None) :
224+
mesh) :
227225
avg_zero = np.zeros([self.ntypes,self.ndescrpt]).astype(global_np_float_precision)
228226
std_ones = np.ones ([self.ntypes,self.ndescrpt]).astype(global_np_float_precision)
229227
sub_graph = tf.Graph()

0 commit comments

Comments
 (0)