-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-gen_diffs.py
60 lines (38 loc) · 1.32 KB
/
4-gen_diffs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import numpy as np
import time
import sklearn as sk
from sklearn import metrics
import gc
import sys
import pickle
init_t = time.time()
at = sys.argv[1]
ref_envs = np.load('./data/train_envs.npy',
allow_pickle=True).item()[at]
reps_dict = np.load('./data/red_reps_dict.npy', allow_pickle=True)
attypes = np.load('./data/attypes.npy', allow_pickle=True)
gc.collect()
t1 = time.time()
with open('progress_gen__diffs_{}.txt'.format(at), 'a') as file:
file.write('Reps loaded, time: {} \n'.format(time.time() - t1))
atom_projections = []
with open('progress_gen__diffs_{}.txt'.format(at), 'a') as file:
file.write('Starting train products at {} \n'.format(time.time() - init_t))
atom_diffs = []
t1 = time.time()
for i in range(len(reps_dict[:])):
repd = reps_dict[i]
rep_at_envs = repd[at]
if len(rep_at_envs) > 0:
atom_diff = sk.metrics.pairwise_distances(
rep_at_envs, ref_envs, n_jobs=-1).T
else:
atom_diff = []
atom_diffs.append(atom_diff)
if i % 100 == 0:
with open('progress_gen__diffs_{}.txt'.format(at), 'a') as file:
file.write(' Train mol {}, cost: {} \n'.format(
i, time.time() - t1))
t1 = time.time()
with open('./euclideans/{}_diffs.npy'.format(at), "wb") as fp:
pickle.dump(atom_diffs, fp)