Esempio n. 1
0
    "eta": 4.0,
    "zeta": 8.0
}

idx = list(range(n_samples))

splitter = modsel.KFold(n_splits=3, random_state=42, shuffle=True)
indices = splitter.split(idx)

all_scores = []

for item in indices:

    estimator = ARMP_G(iterations=1,
                       representation='acsf',
                       representation_params=acsf_params,
                       batch_size=250,
                       tensorboard=True)

    estimator.set_xyz(xyz)
    estimator.set_classes(zs)
    estimator.set_properties(ene)
    estimator.set_gradients(forces)

    estimator.generate_representation(method='fortran')

    idx_train = item[0]
    idx_test = item[1]

    estimator.fit(idx_train)
    score = estimator.score(idx_test)
        float(split_line[3])
    ]
    zs.append(dic[split_line[0]])
    xyz.append(xyz_atom)

    counter += 1

for i in range(19):
    xyz.append([0, 0, 0])
    zs.append(0)

estimator = ARMP_G(iterations=50,
                   representation='acsf',
                   representation_params={
                       "nRs2": 5,
                       "nRs3": 5,
                       "nTs": 2
                   },
                   tensorboard=False,
                   store_frequency=1,
                   batch_size=20)

estimator.load_nn("saved_model")

xyz = np.asarray(xyz)
xyz = np.reshape(xyz, (1, xyz.shape[0], xyz.shape[1]))
zs = np.asarray(zs, dtype=np.int32)
zs = np.reshape(zs, (1, zs.shape[0]))
print(xyz.shape, zs.shape)

ene_2, f_2 = estimator.predict_from_xyz(xyz, zs)
Esempio n. 3
0
from qml.aglaia.aglaia import ARMP_G
import h5py
from sklearn import model_selection as modsel

data = h5py.File("/Volumes/Transcend/data_sets/CN_isopentane/pruned_dft_with_forces/pruned_isopentane_cn_dft.hdf5", "r")

n_samples = 100

xyz = np.array(data.get("xyz")[:n_samples], dtype=np.float32)
ene = np.array(data.get("ene")[:n_samples], dtype=np.float32)*2625.50
ene = ene - data.get("ene")[0]*2625.50
zs = np.array(data["zs"][:n_samples], dtype=np.int32)
forces = np.array(data.get("forces")[:n_samples], dtype=np.float32)

acsf_params = {"nRs2":5, "nRs3":5, "nTs":5, "rcut":5, "acut":5, "zeta":220.127, "eta":30.8065}
estimator = ARMP_G(iterations=5000, l1_reg=0.0, l2_reg=0.0, learning_rate=0.075,
                   representation_name='acsf', representation_params=acsf_params, tensorboard=True, store_frequency=2)

estimator.set_xyz(xyz)
estimator.set_classes(zs)
estimator.set_properties(ene)
estimator.set_gradients(forces)

estimator.generate_representation()

idx = np.arange(0, n_samples)
idx_train, idx_test = modsel.train_test_split(idx, test_size=0, random_state=42, shuffle=True)

# estimator.load_nn()

estimator.fit(idx_train)
# print("Done the fitting")
Esempio n. 4
0
import h5py
from qml.aglaia.aglaia import ARMP_G
from sklearn.base import clone

data = h5py.File("/Volumes/Transcend/data_sets/CN_isobutane_model/pruned_cn_isobutane/train_isopentane_cn_dft.hdf5", "r")

n_samples = 2

xyz = np.array(data.get("xyz")[:n_samples])
ene = np.array(data.get("ene")[:n_samples])*4.184
ene = ene - ene[0]
zs = np.array(data["zs"][:n_samples], dtype = int)
forces = np.array(data.get("forces")[:n_samples])*4.184

acsf_params = {"nRs2":10, "nRs3":10, "nTs": 5, "eta2":4.0, "eta3":4.0, "zeta":8.0}

estimator = ARMP_G(iterations=1, representation='acsf', representation_params=acsf_params, batch_size=2)

estimator.set_xyz(xyz)
estimator.set_classes(zs)
estimator.set_properties(ene)
estimator.set_gradients(forces)

estimator.generate_representation(method='fortran')

pickle.dump(estimator, open('model.pickle', 'wb'))

with open('idx.csv', 'w') as f:
    for i in range(n_samples):
        f.write('%s\n' % i)
xyz = np.array(data.get("xyz"))
ene = np.array(data.get("ene"))*4.184
ene = ene - ene[0]
zs = np.array(data["zs"], dtype = int)
forces = np.array(data.get("forces"))*4.184

n_samples = 10

idx = list(range(n_samples))
splitter = modsel.KFold(n_splits=3, random_state=42, shuffle=True)
indices = splitter.split(idx)

acsf_params = {"radial_rs":np.arange(0,10, 0.6), "angular_rs":np.arange(0.5, 10.5, 0.6), "theta_s": np.arange(0, 3.14, 0.5), "eta":4.0, "zeta":8.0}
estimator = ARMP_G(iterations=2, representation_name='acsf', representation_params=acsf_params, batch_size=512,
                   tensorboard=True, tensorboard_subdir=os.getcwd(), hidden_layer_sizes=(50,30,10),
                   l1_reg=1.273530531541467e-10, l2_reg=0.06740360714223229, learning_rate=0.01, store_frequency=10)

# estimator.set_xyz(xyz[:n_samples])
# estimator.set_classes(zs[:n_samples])
# estimator.set_properties(ene[:n_samples])
# estimator.set_gradients(forces[:n_samples])

all_scores = []
counter = 0

for item in indices:

    dolly = clone(estimator)

    dolly.set_xyz(xyz[:n_samples])
Esempio n. 6
0
import matplotlib.pyplot as plt

data = h5py.File(
    "/Volumes/Transcend/data_sets/CN_isobutane_model/pruned_dft_with_forces/pruned_isopentane_cn_dft.hdf5",
    "r")

n_samples = 100

xyz = np.array(data.get("xyz")[-n_samples:])
ene = np.array(data.get("ene")[-n_samples:]) * 2625.50
ene = ene - data.get("ene")[0] * 2625.50
zs = np.array(data["zs"][-n_samples:], dtype=np.int32)
forces = np.array(data.get("forces")[-n_samples:])

idx = list(range(n_samples))

# Creating the estimator
estimator = ARMP_G(iterations=50, batch_size=10)

estimator.set_xyz(xyz)
estimator.set_properties(ene)
estimator.set_classes(zs)
estimator.set_gradients(forces)

estimator.load_nn()

estimator.predict(idx)

estimator.fit(idx)

estimator.score(idx)
Esempio n. 7
0
    "r")

n_samples = 10

xyz = np.array(data.get("xyz")[:n_samples])
ene = np.array(data.get("ene")[:n_samples]) * 4.184
zs = np.array(data["zs"][:n_samples], dtype=np.int32)
forces = np.array(data.get("forces")[:n_samples]) * 4.184

## ------------- ** Setting up the estimator ** ---------------

estimator = ARMP_G(iterations=10,
                   representation_name='acsf',
                   representation_params={
                       "nRs2": 5,
                       "nRs3": 5,
                       "nTs": 2
                   },
                   tensorboard=False,
                   store_frequency=1,
                   batch_size=20)

estimator.set_xyz(xyz[:n_samples])
estimator.set_classes(zs[:n_samples])
estimator.set_properties(ene[:n_samples])
estimator.set_gradients(forces[:n_samples])

idx = np.arange(0, n_samples)

estimator.fit(idx)
print("\n Done the fitting")
Esempio n. 8
0
import numpy as np
import matplotlib.pyplot as plt

data = h5py.File("/Volumes/Transcend/data_sets/CN_isopentane/pruned_dft_with_forces/pruned_isopentane_cn_dft.hdf5", "r")

n_samples = 10

xyz = np.array(data.get("xyz")[:n_samples])
ene = np.array(data.get("ene")[:n_samples])*2625.50
ene = ene - data.get("ene")[0]*2625.50
zs = np.array(data["zs"][:n_samples], dtype=np.int32)
forces = np.array(data.get("forces")[:n_samples])

# Creating the estimator
estimator = ARMP_G(iterations=10, batch_size=30, hidden_layer_sizes=(40, 20, 10), l2_reg=0.0, tensorboard=False,
                   store_frequency=5, learning_rate=0.001, representation_params={'nRs2':7, 'nRs3':7, 'nTs':7,
                                                                                    'zeta':220.127, 'eta':30.8065})

estimator.set_xyz(xyz)
estimator.set_properties(ene)
estimator.set_classes(zs)
estimator.set_gradients(forces)

idx = list(range(n_samples))
estimator.load_nn("saved_model")
estimator.fit(idx)

pred_ene, pred_forces = estimator.predict(idx)

score = estimator.score(idx)
Esempio n. 9
0
data = h5py.File(
    "/Volumes/Transcend/data_sets/CN_isobutane_model/pruned_cn_isobutane/train_isopentane_cn_dft.hdf5",
    "r")

n_samples = 12

idx = list(range(n_samples))
splitter = modsel.KFold(n_splits=3, random_state=42, shuffle=True)
indices = splitter.split(idx)

xyz = np.array(data.get("xyz")[:n_samples])
ene = np.array(data.get("ene")[:n_samples]) * 4.184
zs = np.array(data["zs"][:n_samples])
forces = np.array(data.get("forces")[:n_samples]) * 4.184

estimator = ARMP_G(representation_params={"nRs2": 5, "nRs3": 5, "nTs": 2})

estimator.load_nn("saved_model")

estimator.set_xyz(xyz[:n_samples])
estimator.set_classes(zs[:n_samples])
estimator.set_properties(ene[:n_samples])
estimator.set_gradients(forces[:n_samples])

# estimator.load_representations_and_dgdr("descrpt_and_grad.hdf5")

idx = np.arange(0, n_samples)
# estimator.fit(idx)

ene_1, f_1 = estimator.predict(idx)
from qml.aglaia.aglaia import ARMP_G
import matplotlib.pyplot as plt

current_dir = os.path.dirname(os.path.realpath(__file__))
data = np.load(current_dir+"/../test/data/CN_isopentane_forces.npz")

xyz = data["arr_0"]
zs = data["arr_1"]
ene = data["arr_2"]
forces = data["arr_3"]

print(xyz.shape, zs.shape, ene.shape, forces.shape)

## ------------- ** Setting up the estimator ** ---------------

estimator = ARMP_G(iterations=1, representation='acsf', representation_params={"radial_rs": np.arange(0,10, 2), "angular_rs": np.arange(0.5, 10.5, 2),
"theta_s": np.arange(0, 3.14, 2.5)}, tensorboard=False, store_frequency=1, batch_size=10)

estimator.set_xyz(xyz[:2])
estimator.set_classes(zs[:2])
estimator.set_properties(ene[:2])
estimator.set_gradients(forces[:2])

estimator.generate_representation()
print(estimator.representation.shape[0])

idx = np.arange(0, 2)
estimator.fit(idx)

ene_1, f_1 = estimator.predict(idx)
ene_2, f_2 = estimator.predict_from_xyz(xyz[:2], zs[:2])
Esempio n. 11
0
from qml.aglaia.aglaia import ARMP_G
import numpy as np

acsf_params = {
    "nRs2": 10,
    "nRs3": 10,
    "nTs": 5,
    "eta2": 4.0,
    "eta3": 4.0,
    "zeta": 8.0
}
estimator = ARMP_G(iterations=5,
                   representation='acsf',
                   representation_params=acsf_params,
                   batch_size=5,
                   l1_reg=0.1,
                   l2_reg=0.3)

parameters = estimator.get_params()

print(parameters["l1_reg"], parameters["l2_reg"])

print(parameters["representation_params"])
Esempio n. 12
0
forces = np.array(data.get("forces")[:n_samples]) * 2625.5

acsf_param = {
    "nRs2": 5,
    "nRs3": 5,
    "nTs": 5,
    "rcut": 5,
    "acut": 5,
    "zeta": 220.127,
    "eta": 30.8065
}
estimator = ARMP_G(iterations=100,
                   representation_name='acsf',
                   representation_params=acsf_param,
                   tensorboard=True,
                   hidden_layer_sizes=(50, 30, 10),
                   l1_reg=0,
                   l2_reg=0,
                   store_frequency=20,
                   learning_rate=0.005)

# estimator.load_nn()

estimator.set_xyz(xyz)
estimator.set_classes(zs)
# estimator.generate_representation(xyz, zs, method='fortran')
estimator.set_properties(ene)
estimator.set_gradients(forces)

estimator.generate_representation(method='fortran')
print("Generated all representations.")
Esempio n. 13
0
current_dir = os.path.dirname(os.path.realpath(__file__))
data = np.load(current_dir + "/../../qml/test/data/CN_isopentane_forces.npz")

xyz = data["arr_0"]
zs = data["arr_1"]
ene = data["arr_2"]
forces = data["arr_3"]

## ------------- ** Setting up the estimator ** ---------------

estimator = ARMP_G(iterations=5,
                   representation_name='acsf',
                   representation_params={
                       "nRs2": 5,
                       "nRs3": 5,
                       "nTs": 2
                   },
                   tensorboard=False,
                   store_frequency=1,
                   batch_size=20,
                   method='fortran')

n_samples = 10

estimator.set_xyz(xyz[:n_samples])
estimator.set_classes(zs[:n_samples])
estimator.set_properties(ene[:n_samples])
estimator.set_gradients(forces[:n_samples])

idx = np.arange(0, n_samples)