-
Notifications
You must be signed in to change notification settings - Fork 14
/
run_exp.py
38 lines (23 loc) · 849 Bytes
/
run_exp.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
import numpy as np
import json
import sys
from kingdra_cluster.unsup_metrics import ACC
from kingdra_cluster.kingdra_cluster import KingdraCluster
import warnings
from keras.backend.tensorflow_backend import set_session
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
set_session(tf.Session(config=config))
warnings.filterwarnings("ignore", category=DeprecationWarning)
config = json.loads(open(sys.argv[1]).read())
gt = np.load(config['ground_truth_path'])
X = np.load(config['training_path'])
del config['ground_truth_path']
del config['training_path']
m = KingdraCluster(**config)
def callback(it, y_pred_e, models):
print("Clustering accuracy at iteration ", it, ACC(gt, y_pred_e))
m.fit(X, callback=callback)
preds_2 = m.predict(X)
print("Clustering Accuracy: ", ACC(gt, preds_2))