print("\nParameters:") for attr, value in sorted(FLAGS.__flags.iteritems()): print("{}={}".format(attr.upper(), value)) print("") # Data Preparatopn # ================================================== # Load data print("Loading data...") x_, y_, vocabulary, vocabulary_inv, test_size = data_helpers.load_data(FLAGS.vn) print(x_) print(y_) print("Loading pre-trained vectors...") trained_vecs = data_helpers.load_trained_vecs( FLAGS.vn, FLAGS.vn_embeddings, FLAGS.en_embeddings, vocabulary) # Create embedding lookup table count = data_helpers.add_unknown_words(trained_vecs, vocabulary) embedding_mat = [trained_vecs[p] for i, p in enumerate(vocabulary_inv)] embedding_mat = np.array(embedding_mat, dtype = np.float32) # Randomly shuffle data x, x_test = x_[:-test_size], x_[-test_size:] y, y_test = y_[:-test_size], y_[-test_size:] shuffle_indices = np.random.permutation(np.arange(len(y))) x_shuffled = x[shuffle_indices] y_shuffled = y[shuffle_indices] if FLAGS.hold_out == 0: x_train = x_shuffled y_train = y_shuffled
FLAGS = tf.flags.FLAGS FLAGS.batch_size print("\nParameters:") for attr, value in sorted(FLAGS.__flags.iteritems()): print("{}={}".format(attr.upper(), value)) print("") # Data Preparatopn # ================================================== # Load data print("Loading data...") x_, y_, vocabulary, vocabulary_inv, test_size = data_helpers.load_data(FLAGS.vn) print("Loading pre-trained vectors...") trained_vecs = data_helpers.load_trained_vecs( FLAGS.vn, FLAGS.vn_embeddings, FLAGS.en_embeddings, vocabulary) # Create embedding lookup table count = data_helpers.add_unknown_words(trained_vecs, vocabulary) embedding_mat = [trained_vecs[p] for i, p in enumerate(vocabulary_inv)] embedding_mat = np.array(embedding_mat, dtype = np.float32) # Randomly shuffle data x, x_test = x_[:-test_size], x_[-test_size:] y, y_test = y_[:-test_size], y_[-test_size:] shuffle_indices = np.random.permutation(np.arange(len(y))) x_shuffled = x[shuffle_indices] y_shuffled = y[shuffle_indices] if FLAGS.hold_out == 0: x_train = x_shuffled y_train = y_shuffled