Esempio n. 1
0
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)
    all_scores.append(score)
    tf.reset_default_graph()

print(all_scores)
Esempio n. 2
0
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. 3
0
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")

ene_pred, f_pred = estimator.predict(idx_train)

plt.scatter(ene_pred, ene[idx_train])
plt.xlabel("Predicted energies (kJ/mol)")
plt.ylabel("DFT energies (kJ/mol)")
# plt.savefig("mem_aglaia_overfit.png", dpi=200)
plt.show()

score = estimator.score(idx_train)
# print("\n The score is %s" % (str(score)))

# os.remove("predict.tfrecords")
# os.remove("training.tfrecords")

# estimator.save_nn()
Esempio n. 4
0
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)

# estimator.save_nn()

plt.scatter(ene, pred_ene)
plt.show()