print("-- Loading index") with open(args.model_filename + ".index", mode="rb") as in_file: index = pickle.load(in_file) token2id = index["token2id"] id2token = index["id2token"] label2id = index["label2id"] id2label = index["id2label"] num_tokens = len(token2id) num_labels = len(label2id) print("-- Loading test set") test_labels, test_padded_premises, test_padded_hypotheses, test_original_premises, test_original_hypotheses =\ load_te_dataset( args.test_filename, token2id, label2id ) print("-- Restoring model") premise_input = tf.placeholder(tf.int32, (None, None), name="premise_input") hypothesis_input = tf.placeholder(tf.int32, (None, None), name="hypothesis_input") label_input = tf.placeholder(tf.int32, (None, ), name="label_input") dropout_input = tf.placeholder(tf.float32, name="dropout_input") logits = build_simple_te_model_h(premise_input, hypothesis_input, dropout_input, num_tokens, num_labels, None, params["embeddings_size"], params["train_embeddings"], params["rnn_hidden_size"],
json.dump(vars(args), out_file) print("Params saved to: {}".format(args.model_save_filename + ".params")) with open(args.model_save_filename + ".index", mode="wb") as out_file: pickle.dump( { "token2id": token2id, "id2token": id2token, "label2id": label2id, "id2label": id2label }, out_file) print("Index saved to: {}".format(args.model_save_filename + ".index")) print("-- Loading training set") train_labels, train_premises, train_hypotheses, _, _ = load_te_dataset( args.train_filename, token2id, label2id) print("-- Loading development set") dev_labels, dev_premises, dev_hypotheses, _, _ = load_te_dataset( args.dev_filename, token2id, label2id) print("-- Building model") premise_input = tf.placeholder(tf.int32, (None, None), name="premise_input") hypothesis_input = tf.placeholder(tf.int32, (None, None), name="hypothesis_input") label_input = tf.placeholder(tf.int32, (None, ), name="label_input") dropout_input = tf.placeholder(tf.float32, name="dropout_input") logits = build_simple_te_model(premise_input, hypothesis_input, dropout_input, num_tokens, num_labels, embeddings, args.embeddings_size,