def load_custom_gru(): root.update() filename = filedialog.askopenfilename(initialdir = os.getcwd(), title = 'Select file', filetypes=[('Numpy Files', '*.npz')]) if filename != "": try: model = GRU(dictionary_size) log_message = model.load_model_parameters(filename) generate_sonnet1_button['state'] = 'normal' generate_sonnet2_button['state'] = 'normal' bigram_flag = False write_to_log(log_message, logger_index) current_model.set("Current Model: Custom GRU") except(FileNotFoundError): write_to_log("No such file or directory: %s" %filename, logger_index) return
def load_custom_gru(): root.update() filename = filedialog.askopenfilename(initialdir = os.getcwd(), title = 'Select file', filetypes=[('Numpy Files', '*.npz')]) if filename != "": try: model = GRU(dictionary_size) log_message = model.load_model_parameters(filename) generate_sonnet1_button['state'] = 'normal' generate_sonnet2_button['state'] = 'normal' bigram_flag = False write_to_log(log_message, logger_index) current_model.set("Current Model: Custom GRU") except(IOError): write_to_log("No such file or directory: %s" %filename, logger_index) return
def load_gru(): iterations = number_iterations.get() if iterations == 20: filename = "GRUModel20.npz" elif iterations == 40: filename = "GRUModel40.npz" elif iterations == 60: filename = "GRUModel60.npz" elif iterations == 80: filename = "GRUModel80.npz" else: filename = "GRUModel100.npz" model = GRU(dictionary_size) log_message = model.load_model_parameters("TrainedModels/" + filename) generate_sonnet1_button['state'] = 'normal' generate_sonnet2_button['state'] = 'normal' generate_sonnet1_image_button['state'] = 'normal' generate_sonnet2_image_button['state'] = 'normal' bigram_flag = False write_to_log(log_message + " iterations=%d" % iterations, logger_index) current_model.set("Current Model: GRU %d iterations" % iterations)
def load_gru(): iterations = number_iterations.get() if iterations == 20: filename = "GRUModel20.npz" elif iterations == 40: filename = "GRUModel40.npz" elif iterations == 60: filename = "GRUModel60.npz" elif iterations == 80: filename = "GRUModel80.npz" else: filename = "GRUModel100.npz" model = GRU(dictionary_size) log_message = model.load_model_parameters("TrainedModels/" + filename) generate_sonnet1_button['state'] = 'normal' generate_sonnet2_button['state'] = 'normal' generate_sonnet1_image_button['state'] = 'normal' generate_sonnet2_image_button['state'] = 'normal' bigram_flag = False write_to_log(log_message + " iterations=%d" %iterations, logger_index) current_model.set("Current Model: GRU %d iterations" %iterations)
for (num_examples, loss) in losses: num_examples_array.append(num_examples) loss_array.append(loss) plt.plot(num_examples_array, loss_array) plt.title('Losses of Trained RNN Model %d iterations' % number_of_iterations) plt.xlabel('number of examples seen') plt.ylabel('losses') plt.grid(True) plt.show() model.save_model_parameters(save_to_file) print("Done training model") # GRU elif args.mode == "GRU": print("Generating GRU Model...") model = GRU(dictionary_size) print("Training GRU Model with %d iterations..." % number_of_iterations) losses = model.train_with_sgd(start_train, end_train, nepoch=number_of_iterations) for (num_examples, loss) in losses: num_examples_array.append(num_examples) loss_array.append(loss) plt.plot(num_examples_array, loss_array) plt.title('Losses of Trained GRU Model %d iterations' % number_of_iterations) plt.xlabel('number of examples seen') plt.ylabel('losses') plt.grid(True) plt.show() model.save_model_parameters(save_to_file)