Commit f3f00efe authored by Margret A. Riegert's avatar Margret A. Riegert
Browse files

Rewrite comm_to_json.py


Former-commit-id: b9676980137d6e3386d349b3eb5753b7919be9ed [formerly 2228018e5ffd53aed31e937ff41bdcddf95b2cd1]
Former-commit-id: 8e1383ba9ba5f6c5a692fed22593b8e0f4da760e
parent 335fc428
......@@ -5,59 +5,25 @@
import sys
import json
import struct
import os
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
import pyinputplus as pyip
def printUsage():
print("python comm_to_json.py <func name>")
exit(1)
def main():
#learning rate
#number of epochs
#sampling rate
#test data fraction
#max n of layers
#max n of neurons per layer
args = []
print("------------------ Compiler Parameters ------------------")
args.append(input(bcolors.OKBLUE + "Learning rate [0.1-1.0]: " + bcolors.ENDC))
args.append(input(bcolors.OKBLUE + "Epoch number [1-10000]: "+ bcolors.ENDC))
args.append(input(bcolors.OKBLUE + "Sampling rate [0.1-1.0]: "+ bcolors.ENDC))
args.append(input(bcolors.OKBLUE + "Test data fraction [0.1-1.0]: "+ bcolors.ENDC))
hidden_layers = input(bcolors.OKBLUE + "Maximum number of layers [3|4]: "+ bcolors.ENDC)
while((int(hidden_layers) != 3 ) and (int(hidden_layers) != 4)):
print((bcolors.FAIL + "Number of hidden layers can only be 3 or 4!" + bcolors.ENDC))
hidden_layers = input(bcolors.OKBLUE + "Maximum number of layers [3|4]: "+ bcolors.ENDC)
args.append(hidden_layers)
args.append(input(bcolors.OKBLUE + "Maximum number of neurons per layer [2-64]: "+ bcolors.ENDC))
print("---------------------------------------------------------")
data_file = open(sys.argv[1] +'.json', 'w')
#quotation marks around ints? decide after running everything
data_file.write('{\n')
data_file.write('\t\"learning_rate\": \"{}\",\n\t\"epoch_number\": \"{}\",\n'.format(args[0], args[1]))
data_file.write('\t\"sampling_rate\": \"{}\",\n\t\"test_data_fraction\": \"{}\",\n'.format(args[2], args [3]))
data_file.write('\t\"max_layer_num\": \"{}\",\n\t\"max_neuron_num_per_layer\": \"{}\"\n'.format(args[4] , args[5]))
data_file.write('}')
data_file.close()
pass;
print("python comm_to_json.py <func name>")
exit(1)
def main():
args = {}
print("------------------ Compiler Parameters ------------------")
args['learning_rate'] = pyip.inputFloat('Learning rate [0.1-1.0]: ', min = 0.1, max = 1.0)
args['epoch_number'] = pyip.inputInt('Epoch number [1-10000]: ', min=1, max=10000)
args['sampling_rate'] = pyip.inputFloat('Sampling rate [0.1-1.0]: ', min=0.1, max=1.0)
args['test_data_fraction'] = pyip.inputFloat('Test data fraction [0.1-1.0]: ', min=0.1, max=1.0)
args['max_layer_num'] = pyip.inputInt('Maximum number of layers [3|4]: ', min=3, max=4)
args['max_neuron_num_per_layer'] = pyip.inputInt('Maximum number of neurons per layer [2-64]: ', min=2, max=64)
print("---------------------------------------------------------")
with open(sys.argv[1] + '.json', 'w+') as outfile:
json.dump(args, outfile)
if __name__ == "__main__":
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment