-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·66 lines (31 loc) · 951 Bytes
/
test.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
61
62
63
64
65
#!/usr/bin/env python
# coding: utf-8
# In[8]:
import numpy as np
import tensorflow as tf
# In[9]:
def generate_data(data):
X = np.genfromtxt(data, delimiter=',')
data_points = X.shape[0] // X.shape[1]
X = X.reshape((data_points, X.shape[1], X.shape[1], 1))
return X
# In[10]:
def get_predictions(modal, data):
output = modal.predict(X_test)
predictions = np.zeros(output.shape)
predictions[np.arange(predictions.shape[0]), output.argmax(axis=1)] = 1
return predictions
# In[11]:
def create_output_file(predictions):
value_vector = predictions.astype(str)
with open('labels.txt', 'w+') as f:
for val in value_vector:
f.write(val + '\n')
# In[12]:
model = tf.keras.models.load_model('tox-model.h5')
# In[13]:
X_test = generate_data('../Tox21_AR/score_graphs.csv')
# In[14]:
output = model.predict_classes(X_test, 2)
# In[15]:
create_output_file(output)