DECAY = np.random.random_sample([number_of_exp]) DECAY = np.append(DECAY, 0.96) number_of_exp += 1 DECAY.sort() results = [] duration = [] info = [] for i, de in enumerate(DECAY): print("\n ({0} of {1})".format(i + 1, number_of_exp)) my_config = Config(tunning=True, decay_rate=de) attrs = vars(my_config) config_info = ["%s: %s" % item for item in attrs.items()] info.append(config_info) my_model = CNNModel(my_config, my_dataholder) train_model(my_model, my_dataholder, 10001, 1000, False) current_dur = get_time(train_model, 10001) score = check_valid(my_model) results.append(score) duration.append(current_dur) DECAY = list(DECAY) best_result = max(list(zip(results, DECAY, duration, info))) result_string = """In an experiment with {0} decay rate values the best one is {1} with valid accuracy = {2}. \nThe training takes {3:.2f} seconds using the following params: \n{4}""".format(number_of_exp, best_result[1], best_result[0], best_result[2], best_result[3])
DP = np.random.random_sample([number_of_exp]) DP = np.append(DP, 0.99) number_of_exp += 1 DP.sort() results = [] duration = [] info = [] for i, dro in enumerate(DP): print("\n ({0} of {1})".format(i + 1, number_of_exp)) my_config = Config(tunning=True, dropout=dro) attrs = vars(my_config) config_info = ["%s: %s" % item for item in attrs.items()] info.append(config_info) my_model = CNNModel(my_config, my_dataholder) train_model(my_model, my_dataholder, 3, 2, False) current_dur = get_time(train_model, 3) score = check_valid(my_model) results.append(score) duration.append(current_dur) DP = list(DP) best_result = max(list(zip(results, DP, duration, info))) result_string = """In an experiment with {0} dropout values the best one is {1} with valid accuracy = {2}. \nThe training takes {3:.2f} seconds using the following params: \n{4}""".format(number_of_exp, best_result[1], best_result[0], best_result[2], best_result[3]) file = open("dropout.txt", "w") file.write(result_string)