-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_index.py
More file actions
executable file
·55 lines (52 loc) · 1.55 KB
/
find_index.py
File metadata and controls
executable file
·55 lines (52 loc) · 1.55 KB
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
#!/usr/bin/python3
'''
Abstract:
This is a program for find the index of each label in label predicted files.
Usage:
find_index.py [label_pred.txt]
Output:
1. cls_pred files
2. star index
3. gala index
4. ysos index
Editor:
Jacob975
##################################
# Python3 #
# This code is made in python3 #
##################################
20190906
####################################
update log
'''
import tensorflow as tf
import time
import numpy as np
from sys import argv
#--------------------------------------------
# Main code
if __name__ == "__main__":
VERBOSE = 0
# Measure time
start_time = time.time()
#-----------------------------------
# Load argv
if len(argv) != 2:
print ("The number of arguments is wrong.")
print ("Usage: find_index.py [label_pred.txt]")
exit()
inp_table_name = argv[1]
#-----------------------------------
inp_table = np.loadtxt(inp_table_name)
cls_pred = np.argmax(inp_table, axis = 1)
star_index = np.where(cls_pred == 0)
gala_index = np.where(cls_pred == 1)
ysos_index = np.where(cls_pred == 2)
np.savetxt('student_cls_pred.txt', cls_pred, fmt = '%d')
np.savetxt('star_index.txt', star_index, fmt = '%d')
np.savetxt('gala_index.txt', gala_index, fmt = '%d')
np.savetxt('ysos_index.txt', ysos_index, fmt = '%d')
#-----------------------------------
# Measure time
elapsed_time = time.time() - start_time
print("Exiting Main Program, spending ", elapsed_time, "seconds.")