Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Develop #98

Merged
merged 71 commits into from
Dec 12, 2018
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
baa57eb
Merge remote-tracking branch 'upstream/develop' into develop
SilviaAmAm Jul 30, 2018
ceb9ef5
Merge remote-tracking branch 'upstream/develop' into develop
SilviaAmAm Aug 15, 2018
d974133
SilviaAmAm Aug 24, 2018
8a3fbf3
Started updating so that model can be trained after its been reloaded
SilviaAmAm Aug 24, 2018
7a2dc7e
SilviaAmAm Aug 25, 2018
b33a537
Merge remote-tracking branch 'upstream/develop' into develop
SilviaAmAm Aug 25, 2018
5525d3b
Updated model so one can predict from xyz and disabled shuffling in t…
SilviaAmAm Aug 26, 2018
bb28c4a
SilviaAmAm Aug 27, 2018
4b29b95
Added some tests to make sure the predictions work
SilviaAmAm Aug 27, 2018
a4dc496
SilviaAmAm Aug 27, 2018
ef5c880
SilviaAmAm Aug 28, 2018
d1e27ad
SilviaAmAm Aug 28, 2018
f3a3e9c
Modified the name of a parameter
SilviaAmAm Aug 29, 2018
c77272e
Made modifications to make te symmetry functions more numerically stable
SilviaAmAm Aug 31, 2018
3db69a3
SilviaAmAm Sep 5, 2018
acf0ee7
SilviaAmAm Sep 5, 2018
49b36c2
SilviaAmAm Sep 6, 2018
75aac67
SilviaAmAm Sep 6, 2018
1f694f8
SilviaAmAm Sep 7, 2018
e5c4787
Attempt at fixing issue #10
SilviaAmAm Sep 11, 2018
fef6fba
another attempt at fixing #10
SilviaAmAm Sep 11, 2018
61fefce
Removed a pointless line
SilviaAmAm Sep 12, 2018
386be84
Merge
SilviaAmAm Sep 13, 2018
4c050f7
set-up
SilviaAmAm Sep 13, 2018
3bdd928
SilviaAmAm Sep 13, 2018
81c9824
Modifications which prevent installation from breaking on BC4
Sep 13, 2018
f4a7424
Merge branch 'kill_gracefully' into develop
SilviaAmAm Sep 13, 2018
4a41f14
Modification to add neural networks to qmlearn
SilviaAmAm Sep 14, 2018
7d7f580
Merge remote-tracking branch 'upstream/develop' into develop_qmlearn
SilviaAmAm Sep 18, 2018
898b640
Fix for issue #8
SilviaAmAm Sep 21, 2018
f77d040
SilviaAmAm Sep 24, 2018
2d5988f
SilviaAmAm Sep 24, 2018
da8b524
SilviaAmAm Sep 25, 2018
227e2b8
SilviaAmAm Sep 25, 2018
250031d
SilviaAmAm Sep 25, 2018
687291b
uncommented examples
SilviaAmAm Sep 25, 2018
4391906
Removed unique_elements in data class
larsbratholm Sep 26, 2018
2fb8d39
Made tensorflow an optional dependency
larsbratholm Sep 26, 2018
819fa71
Made is_numeric non-private and removed legacy code
larsbratholm Sep 26, 2018
20ca689
Added 1d array util function
larsbratholm Sep 27, 2018
9ef8c10
Removed QML check and moved functions from utils to tf_utils
larsbratholm Sep 27, 2018
00a2a7c
Support for linear models (no hidden layers)
larsbratholm Sep 27, 2018
a925ee0
fixed import bug in tf_utils
larsbratholm Sep 27, 2018
c8cf008
Added text to explain that you are scoring on training set
larsbratholm Sep 27, 2018
96713c0
Restructure.
larsbratholm Sep 28, 2018
f313eff
Moved documentation from init to class
larsbratholm Sep 28, 2018
20b78b8
Constant features will now be removed at fit/predict time
larsbratholm Sep 28, 2018
4b785f1
Moved get_batch_size back into utils, since it doesn't depend on tf
larsbratholm Sep 28, 2018
8d62084
Made the NeuralNetwork class compliant with sklearn
larsbratholm Sep 28, 2018
d8447e7
Fixed tests that didn't pass
larsbratholm Sep 28, 2018
a8f6062
Fixed mistake in checks of set_classes() in ARMP
SilviaAmAm Sep 28, 2018
d4d98b6
SilviaAmAm Oct 1, 2018
9539704
Merge remote-tracking branch 'upstream/develop' into develop
SilviaAmAm Oct 1, 2018
2b22aa3
Fixed bug in padding and added examples that give low errors
SilviaAmAm Oct 1, 2018
8f082c5
Attempted fix to make representations single precision
SilviaAmAm Oct 2, 2018
21fd2fd
Hot fix for AtomScaler
SilviaAmAm Oct 2, 2018
f2f7770
Merge pull request #13 from larsbratholm/nn_qmlearn
Oct 2, 2018
999301d
Merge branch 'develop_qmlearn' into develop
SilviaAmAm Oct 2, 2018
9ce72c6
Minor bug fixes
SilviaAmAm Oct 2, 2018
70e8622
SilviaAmAm Oct 2, 2018
89dfda9
Fixed some tests that had failures
SilviaAmAm Oct 3, 2018
908da82
SilviaAmAm Oct 3, 2018
c47ad62
SilviaAmAm Oct 3, 2018
fdc485e
Readded changes to tests
SilviaAmAm Oct 3, 2018
255ea74
Modifications after code review
SilviaAmAm Oct 3, 2018
de3192f
Merge remote-tracking branch 'upstream/develop' into develop
SilviaAmAm Oct 23, 2018
e2feecf
Version with the ACSF basis functions starting at 0.8 A
Dec 11, 2018
162c811
Merge remote-tracking branch 'origin/develop' into develop
SilviaAmAm Dec 11, 2018
c8e2886
Merge remote-tracking branch 'upstream/develop' into develop
SilviaAmAm Dec 11, 2018
9584817
Updated ACSF representations so that the minimum distance at which to…
SilviaAmAm Dec 12, 2018
0639a32
SilviaAmAm Dec 12, 2018
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
17 changes: 12 additions & 5 deletions qml/aglaia/aglaia.py
Original file line number Diff line number Diff line change
@@ -594,7 +594,7 @@ def _set_acsf_parameters(self, params):
"""

self.acsf_parameters = {'rcut': 5.0, 'acut': 5.0, 'nRs2': 5, 'nRs3': 5, 'nTs': 5,
'zeta': 220.127, 'eta': 30.8065}
'zeta': 220.127, 'eta': 30.8065, 'bin_min': 0.8}

if params is not None:
for key, value in params.items():
@@ -842,6 +842,10 @@ def _check_acsf_values(self):
if is_numeric_array(self.acsf_parameters['zeta']):
raise InputError("Expecting a scalar value for zeta. Got %s." % (self.acsf_parameters['zeta']))

if not is_positive_or_zero(self.acsf_parameters['bin_min']):
raise InputError(
"Expected positive or zero float for variable 'bin_min'. Got %s." % str(self.acsf_parameters['bin_min']))

def _get_msize(self, pad = 0):
"""
Gets the maximum number of atoms in a single molecule. To support larger molecules
@@ -1695,7 +1699,8 @@ def _generate_acsf_tf(self, xyz, classes):
nRs2=self.acsf_parameters['nRs2'],
nRs3=self.acsf_parameters['nRs3'],
nTs=self.acsf_parameters['nTs'], eta=self.acsf_parameters['eta'],
zeta=self.acsf_parameters['zeta'])
zeta=self.acsf_parameters['zeta'],
bin_min=self.acsf_parameters['bin_min'])

sess = tf.Session()
sess.run(tf.global_variables_initializer())
@@ -1765,7 +1770,8 @@ def _generate_acsf_fortran(self, xyz, classes):
nTs=self.acsf_parameters['nTs'],
eta2=self.acsf_parameters['eta'],
eta3=self.acsf_parameters['eta'],
zeta=self.acsf_parameters['zeta'])
zeta=self.acsf_parameters['zeta'],
bin_min=self.acsf_parameters['bin_min'])

padded_g = np.zeros((initial_natoms, g.shape[-1]))
padded_g[:g.shape[0], :] = g
@@ -2121,7 +2127,7 @@ def _check_representation_parameters(self, parameters):
elif self.representation_name == "acsf":

acsf_parameters = {'rcut': 5.0, 'acut': 5.0, 'nRs2': 5, 'nRs3': 5, 'nTs': 5,
'zeta': 220.127, 'eta': 30.8065}
'zeta': 220.127, 'eta': 30.8065, 'bin_min':0.8}

for key, value in parameters.items():
try:
@@ -2423,7 +2429,8 @@ def _build_model_from_xyz(self, n_atoms, element_weights, element_biases):
nRs3=self.acsf_parameters['nRs3'],
nTs=self.acsf_parameters['nTs'],
eta=self.acsf_parameters['eta'],
zeta=self.acsf_parameters['zeta'])
zeta=self.acsf_parameters['zeta'],
bin_min=self.acsf_parameters['bin_min'])

with tf.name_scope("Model_pred"):
batch_energies_nn = self._model(batch_representation, batch_zs, element_weights, element_biases)
7 changes: 4 additions & 3 deletions qml/aglaia/np_symm_funct.py
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ def acsf_ang(xyzs, Zs, element_pairs, angular_cutoff, angular_rs, theta_s, zeta,
return np.asarray(total_descriptor)

def generate_acsf_np(xyzs, Zs, elements, element_pairs, rcut, acut, nRs2,
nRs3, nTs, zeta, eta):
nRs3, nTs, zeta, eta, bin_min):
"""
This function calculates the symmetry functions used in the tensormol paper.

@@ -203,11 +203,12 @@ def generate_acsf_np(xyzs, Zs, elements, element_pairs, rcut, acut, nRs2,
:param theta_s: list of all the thetas parameters. Numpy array of shape (n_thetas,)
:param zeta: parameter. scalar.
:param eta: parameter. scalar.
:param bin_min: value at which to start the binning of the distances
:return: numpy array of shape (n_samples, n_atoms, n_rad_rs*n_elements + n_ang_rs*n_thetas*n_element_pairs)
"""

radial_rs = np.linspace(0, rcut, nRs2)
angular_rs = np.linspace(0, acut, nRs3)
radial_rs = np.linspace(bin_min, rcut, nRs2)
angular_rs = np.linspace(bin_min, acut, nRs3)
theta_s = np.linspace(0, np.pi, nTs)

rad_term = acsf_rad(xyzs, Zs, elements, rcut, radial_rs, eta)
8 changes: 5 additions & 3 deletions qml/aglaia/symm_funct.py
Original file line number Diff line number Diff line change
@@ -381,7 +381,7 @@ def sum_ang(pre_sumterm, Zs, element_pairs_list, angular_rs, theta_s):
return clean_final_term

def generate_acsf_tf(xyzs, Zs, elements, element_pairs, rcut, acut,
nRs2, nRs3, nTs, zeta, eta):
nRs2, nRs3, nTs, zeta, eta, bin_min):
"""
This function generates the atom centred symmetry function as used in the Tensormol paper. Currently only tested for
single systems with many conformations. It requires the coordinates of all the atoms in each data sample, the atomic
@@ -410,13 +410,15 @@ def generate_acsf_tf(xyzs, Zs, elements, element_pairs, rcut, acut,
:type zeta: scalar float
:param eta: parameter in the exponential terms
:type eta: scalar float
:param bin_min: the value at which to start binning the distances
:type bin_min: positive float

:return: the atom centred symmetry functions
:rtype: a tf tensor of shape a tf tensor of shape (n_samples, n_atoms, nRs2 * n_elements + nRs3 * nTs * n_elementpairs)
"""

radial_rs = np.linspace(0, rcut, nRs2)
angular_rs = np.linspace(0, acut, nRs3)
radial_rs = np.linspace(bin_min, rcut, nRs2)
angular_rs = np.linspace(bin_min, acut, nRs3)
theta_s = np.linspace(0, np.pi, nTs)

with tf.name_scope("acsf_params"):
8 changes: 5 additions & 3 deletions qml/data/compound.py
Original file line number Diff line number Diff line change
@@ -295,7 +295,7 @@ def generate_slatm(self, mbtypes,
self.representation = slatm

def generate_acsf(self, elements = [1,6,7,8,16], nRs2 = 3, nRs3 = 3, nTs = 3, eta2 = 1,
eta3 = 1, zeta = 1, rcut = 5, acut = 5, gradients = False):
eta3 = 1, zeta = 1, rcut = 5, acut = 5, bin_min=0.8, gradients = False):
"""
Generate the variant of atom-centered symmetry functions used in https://doi.org/10.1039/C7SC04934J

@@ -317,12 +317,14 @@ def generate_acsf(self, elements = [1,6,7,8,16], nRs2 = 3, nRs3 = 3, nTs = 3, et
:type rcut: float
:param acut: Cut-off radius of the three-body terms
:type acut: float
:param bin_min: the value at which to start binning the distances
:type bin_min: positive float
:param gradients: To return gradients or not
:type gradients: boolean
"""

Rs2 = np.linspace(0, rcut, nRs2)
Rs3 = np.linspace(0, acut, nRs3)
Rs2 = np.linspace(bin_min, rcut, nRs2)
Rs3 = np.linspace(bin_min, acut, nRs3)
Ts = np.linspace(0, np.pi, nTs)
n_elements = len(elements)
natoms = len(self.coordinates)
10 changes: 6 additions & 4 deletions qml/representations/representations.py
Original file line number Diff line number Diff line change
@@ -549,8 +549,8 @@ def generate_slatm(coordinates, nuclear_charges, mbtypes,

return mbs

def generate_acsf(nuclear_charges, coordinates, elements = [1,6,7,8,16], nRs2 = 3, nRs3 = 3, nTs = 3, eta2 = 1,
eta3 = 1, zeta = 1, rcut = 5, acut = 5, gradients = False):
def generate_acsf(nuclear_charges, coordinates, elements = [1,6,7,8,16], nRs2 = 3, nRs3 = 3, nTs = 3, eta2 = 1,
eta3 = 1, zeta = 1, rcut = 5, acut = 5, bin_min=0.8, gradients = False):
"""
Generate the variant of atom-centered symmetry functions used in https://doi.org/10.1039/C7SC04934J

@@ -576,14 +576,16 @@ def generate_acsf(nuclear_charges, coordinates, elements = [1,6,7,8,16], nRs2 =
:type rcut: float
:param acut: Cut-off radius of the three-body terms
:type acut: float
:param bin_min: the value at which to start binning the distances
:type bin_min: positive float
:param gradients: To return gradients or not
:type gradients: boolean
:return: Atom-centered symmetry functions representation
:rtype: numpy array
"""

Rs2 = np.linspace(0, rcut, nRs2)
Rs3 = np.linspace(0, acut, nRs3)
Rs2 = np.linspace(bin_min, rcut, nRs2)
Rs3 = np.linspace(bin_min, acut, nRs3)
Ts = np.linspace(0, np.pi, nTs)
n_elements = len(elements)
natoms = len(coordinates)
11 changes: 6 additions & 5 deletions test/test_acsf.py
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ def test_acsf_1():
acut = 5
zeta = 220.127
eta = 30.8065
bin_min = 0.0

input_data = test_dir + "/data/data_test_acsf.npz"
data = np.load(input_data)
@@ -65,13 +66,13 @@ def test_acsf_1():
zs_tf = tf.placeholder(shape=[n_samples, n_atoms], dtype=tf.int32, name="zs")
xyz_tf = tf.placeholder(shape=[n_samples, n_atoms, 3], dtype=tf.float32, name="xyz")

acsf_tf_t = symm_funct.generate_acsf_tf(xyz_tf, zs_tf, elements, element_pairs, rcut, acut, nRs2, nRs3, nTs, zeta, eta)
acsf_tf_t = symm_funct.generate_acsf_tf(xyz_tf, zs_tf, elements, element_pairs, rcut, acut, nRs2, nRs3, nTs, zeta, eta, bin_min)

sess = tf.Session()
sess.run(tf.global_variables_initializer())
acsf_tf = sess.run(acsf_tf_t, feed_dict={xyz_tf: xyzs, zs_tf: zs})

acsf_np = np_symm_funct.generate_acsf_np(xyzs, zs, elements, element_pairs, rcut, acut, nRs2, nRs3, nTs, zeta, eta)
acsf_np = np_symm_funct.generate_acsf_np(xyzs, zs, elements, element_pairs, rcut, acut, nRs2, nRs3, nTs, zeta, eta, bin_min)

n_samples = xyzs.shape[0]
n_atoms = xyzs.shape[1]
@@ -97,6 +98,7 @@ def test_acsf_2():
acut = 5
zeta = 220.127
eta = 30.8065
bin_min = 0.0

input_data = test_dir + "/data/qm7_testdata.npz"
data = np.load(input_data)
@@ -113,13 +115,13 @@ def test_acsf_2():
zs_tf = tf.placeholder(shape=[n_samples, max_n_atoms], dtype=tf.int32, name="zs")
xyz_tf = tf.placeholder(shape=[n_samples, max_n_atoms, 3], dtype=tf.float32, name="xyz")

acsf_tf_t = symm_funct.generate_acsf_tf(xyz_tf, zs_tf, elements, element_pairs, rcut, acut, nRs2, nRs3, nTs, zeta, eta)
acsf_tf_t = symm_funct.generate_acsf_tf(xyz_tf, zs_tf, elements, element_pairs, rcut, acut, nRs2, nRs3, nTs, zeta, eta, bin_min)

sess = tf.Session()
sess.run(tf.global_variables_initializer())
acsf_tf = sess.run(acsf_tf_t, feed_dict={xyz_tf: xyzs, zs_tf: zs})

acsf_np = np_symm_funct.generate_acsf_np(xyzs, zs, elements, element_pairs, rcut, acut, nRs2, nRs3, nTs, zeta, eta)
acsf_np = np_symm_funct.generate_acsf_np(xyzs, zs, elements, element_pairs, rcut, acut, nRs2, nRs3, nTs, zeta, eta, bin_min)

for i in range(n_samples):
for j in range(max_n_atoms):
@@ -130,7 +132,6 @@ def test_acsf_2():
acsf_tf_sort = np.sort(acsf_tf[i][j])
np.testing.assert_array_almost_equal(acsf_np_sort, acsf_tf_sort, decimal=4)


if __name__ == "__main__":
test_acsf_1()
test_acsf_2()
15 changes: 8 additions & 7 deletions test/test_symm_funct.py
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ def test_acsf():
"qm7/0110.xyz"]


path = test_dir = os.path.dirname(os.path.realpath(__file__))
path = os.path.dirname(os.path.realpath(__file__))

mols = []
for xyz_file in files:
@@ -85,7 +85,7 @@ def fort_acsf(mols, path, elements):
# Generate atom centered symmetry functions representation
# using the Compound class
for i, mol in enumerate(mols):
mol.generate_acsf(elements = elements)
mol.generate_acsf(elements = elements, bin_min=0.0)

X_test = np.concatenate([mol.representation for mol in mols])
X_ref = np.loadtxt(path + "/data/acsf_representation.txt")
@@ -96,8 +96,8 @@ def fort_acsf(mols, path, elements):
rep = []
for i, mol in enumerate(mols):
rep.append(generate_acsf(coordinates = mol.coordinates,
nuclear_charges = mol.nuclear_charges,
elements = elements))
nuclear_charges = mol.nuclear_charges,
elements = elements, bin_min=0.0))

X_test = np.concatenate(rep)
X_ref = np.loadtxt(path + "/data/acsf_representation.txt")
@@ -111,6 +111,7 @@ def tf_acsf(mols, path, elements):
n_theta_s = 3
zeta = 1.0
eta = 1.0
bin_min=0.0

element_pairs = []
for i, ei in enumerate(elements):
@@ -128,7 +129,7 @@ def tf_acsf(mols, path, elements):
zs_tf = tf.placeholder(shape=[n_samples, max_n_atoms], dtype=tf.int32, name="zs")
xyz_tf = tf.placeholder(shape=[n_samples, max_n_atoms, 3], dtype=tf.float32, name="xyz")

acsf_tf_t = symm_funct.generate_acsf_tf(xyz_tf, zs_tf, elements, element_pairs, radial_cutoff, angular_cutoff, n_radial_rs, n_angular_rs, n_theta_s, zeta, eta)
acsf_tf_t = symm_funct.generate_acsf_tf(xyz_tf, zs_tf, elements, element_pairs, radial_cutoff, angular_cutoff, n_radial_rs, n_angular_rs, n_theta_s, zeta, eta, bin_min)

sess = tf.Session()
sess.run(tf.global_variables_initializer())
@@ -142,7 +143,7 @@ def fort_acsf_gradients(mols, path, elements):
# Generate atom centered symmetry functions representation
# and gradients using the Compound class
for i, mol in enumerate(mols):
mol.generate_acsf(elements = elements, gradients = True)
mol.generate_acsf(elements = elements, gradients = True, bin_min=0.0)

X_test = np.concatenate([mol.representation for mol in mols])
X_ref = np.loadtxt(path + "/data/acsf_representation.txt")
@@ -159,7 +160,7 @@ def fort_acsf_gradients(mols, path, elements):
grad = []
for i, mol in enumerate(mols):
r, g = generate_acsf(coordinates = mol.coordinates, nuclear_charges = mol.nuclear_charges,
elements = elements, gradients = True)
elements = elements, gradients = True, bin_min=0.0)
rep.append(r)
grad.append(g)