def re_evalute(CONST): threshold = float(CONST.THRESHOLD) from util.utils import load_pickle as load gru = load(CONST.DATA_DIR + "GRU" + "predictions") lstm = load(CONST.DATA_DIR + "LSTM" + "predictions") biRNN = load(CONST.DATA_DIR + "BiRNN" + "predictions") print("########### GRU ###############") find_best_slot1("gru", gru["predictions"], gru["y"]) print("########### LSTM ##############") find_best_slot1("lstm", lstm["predictions"], lstm["y"]) print("########### BiRNN LSTM ##############") find_best_slot1("birnn", biRNN["predictions"], biRNN["y"])
def make_loss_graph(CONST): from util.utils import load_pickle as load gru = load(CONST.DATA_DIR + 'GRU') lstm = load(CONST.DATA_DIR + 'LSTM') birnn = load(CONST.DATA_DIR + 'BiRNN') cutoff = 105 gru = gru[:cutoff] lstm = lstm[:cutoff] birnn= birnn[:cutoff] import matplotlib.pyplot as plt x = [i for i in range(cutoff)] plt.plot(np.array(x), np.array(gru)) plt.plot(np.array(x), np.array(lstm)) plt.plot(np.array(x), np.array(birnn)) plt.legend(['GRU', 'LSTM', 'BiRNN LSTM'], loc='upper right') plt.savefig("losses_all.png") print("all losses plot saved")
from util.heatmap import avg_distance_and_heatmaps avg_distance_and_heatmaps(alphas, sentences, CONST.SENTENCE_PATH + "hursh/") if __name__ == "__main__": # Set and Overload Arguments CONST.parse_argument(argparse.ArgumentParser()) # Set Time of Experiment now = datetime.datetime.now() time_stamp = "_".join([ str(a) for a in [now.month, now.day, now.hour, now.minute, now.second] ]) data = load(CONST.DATA_DIR + CONST.DATA_FILE) """ x_train = data["x_train"] x_dev = data["x_dev"] x_test = data["x_test"] y_train = data["y_train"] y_dev = data["y_dev"] y_test = data["y_test"] l_train = data["l_train"] l_dev = data["l_dev"] l_test = data["l_test"] train_sentences = data["train_sentences"] dev_sentences = data["dev_sentences"] test_sentences = data["test_sentences"] embeddings = data["embeddings"] aspects = data["aspects"]
def re_evalute_slot3(CONST): from util.utils import load_pickle as load birnn = load(CONST.DATA_DIR + "BiRNNslot3" + "_predictions") evaluate_multiclass(birnn["predictions"], birnn["y"], True)