-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5-gen_projections.py
56 lines (37 loc) · 1.59 KB
/
5-gen_projections.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
import numpy as np
import time
import sys
init_t = time.time()
at = sys.argv[1]
t1 = time.time()
ref_envs = np.load('./data/train_envs.npy',
allow_pickle=True).item()[at]
with open('progress_gen__proj_{}.txt'.format(at), 'a') as file:
file.write('Reps loaded, time: {} \n'.format(time.time() - t1))
def kernel(pp, sig):
return np.exp(- pp ** 2 / (2 * sig**2))
with open('progress_gen__proj_{}.txt'.format(at), 'a') as file:
file.write('Starting train products at {} \n'.format(time.time() - init_t))
atom_diffs = np.load('./euclideans/{}_diffs.npy'.format(at), allow_pickle=True)
t1 = time.time()
sigmas = np.linspace(0.1, 10, 10)
sigma_projections = {}
for sigma in sigmas:
with open('progress_gen__proj_{}.txt'.format(at), 'a') as file:
file.write('Starting sigma{} at {} \n'.format(sigma,
time.time() - init_t))
atom_projections = []
for i in range(len(atom_diffs)):
atom_diff = atom_diffs[i]
if len(atom_diff) > 0:
atom_projections.append(np.sum(kernel(np.array(atom_diff), sigma),
axis=1))
else:
atom_projections.append(np.zeros(len(ref_envs)))
if i % 100 == 0:
with open('progress_gen__proj_{}.txt'.format(at), 'a') as file:
file.write(' Train mol {}, cost: {} \n'.format(
i, time.time() - t1))
t1 = time.time()
sigma_projections[sigma] = np.array(atom_projections)
np.save('./projections/{}_projections'.format(at), sigma_projections)