-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreduce.py
More file actions
71 lines (55 loc) · 2.36 KB
/
reduce.py
File metadata and controls
71 lines (55 loc) · 2.36 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import tensorflow as tf
import tensorflow.keras as keras
import logging
import sys
sys.path.append("../utils")
sys.path.append("reduce_utilities")
from utils import *
from interface_utils import *
from reduce_utils import *
from reduce_interface_utils import *
def main(args):
""" main() driver function """
# first make sure that the paths to the provided dataset & queryset are valid
if filepath_is_not_valid(args.dataset):
logging.error("The path {} is not a file. Aborting..".format(args.dataset))
exit()
if filepath_is_not_valid(args.queryset):
logging.error("The path {} is not a file. Aborting..".format(args.queryset))
exit()
# then make sure that the paths to the output files are accessible
if not filepath_can_be_reached(args.output_dataset):
logging.error("The path {} cannot be reached to create file. Aborting..".format(args.output_dataset))
exit()
if not filepath_can_be_reached(args.output_queryset):
logging.error("The path {} cannot be reached to create file. Aborting..".format(args.output_queryset))
exit()
# get the data from the training set
dataset = parse_dataset(args.dataset)
queryset = parse_dataset(args.queryset)
rows = dataset.shape[1]
columns = dataset.shape[2]
# apply preprocessing
dataset = preprocess(dataset, rows, columns)
queryset = preprocess(queryset, rows, columns)
encoder_path = '../autoencoder/output/z4.h5'
# initialize model
model = initialize_encoder(rows, columns, encoder_path)
# pass the sets through the encoder
ds_latent = model.predict(dataset)
qs_latent = model.predict(queryset)
# calculate the min & max values of the dataset latent vectors' values
dsv_min, dsv_max = calculate_min_max(ds_latent)
# produce the dataset and queryset output files
produce_output_file(model, args.output_dataset, ds_latent, dsv_min, dsv_max, 25500)
produce_output_file(model, args.output_queryset, qs_latent, dsv_min, dsv_max, 25500)
if __name__ == "__main__":
""" call main() function here """
print()
# configure the level of the logging and the format of the messages
logging.basicConfig(level=logging.ERROR, format="%(levelname)s: %(message)s\n")
# parse the command line input
args = parse_input()
# call the main() driver function
main(args)
print("\n")