Python utils.read_data() Examples
The following are 3
code examples of utils.read_data().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
utils
, or try the search function
.
Example #1
Source File: main.py From IAN with MIT License | 6 votes |
def main(_): start_time = time.time() print('Loading data info ...') word2id, FLAGS.max_aspect_len, FLAGS.max_context_len = get_data_info(dataset, pre_processed) print('Loading training data and testing data ...') train_data = read_data(word2id, FLAGS.max_aspect_len, FLAGS.max_context_len, dataset + 'train', pre_processed) test_data = read_data(word2id, FLAGS.max_aspect_len, FLAGS.max_context_len, dataset + 'test', pre_processed) print('Loading pre-trained word vectors ...') FLAGS.embedding_matrix = load_word_embeddings(embedding_file_name, FLAGS.embedding_dim, word2id) model = IAN(FLAGS) run(model, train_data, test_data) end_time = time.time() print('Time Costing: %s' % (end_time - start_time))
Example #2
Source File: test.py From next-prediction with Apache License 2.0 | 5 votes |
def main(args): """Run testing.""" test_data = utils.read_data(args, "test") print("total test samples:%s" % test_data.num_examples) if args.random_other: print("warning, testing mode with 'random_other' will result in " "different results every run...") model = models.get_model(args, gpuid=args.gpuid) tfconfig = tf.ConfigProto(allow_soft_placement=True) tfconfig.gpu_options.allow_growth = True tfconfig.gpu_options.visible_device_list = "%s" % ( ",".join(["%s" % i for i in [args.gpuid]])) with tf.Session(config=tfconfig) as sess: utils.initialize(load=True, load_best=args.load_best, args=args, sess=sess) # load the graph and variables tester = models.Tester(model, args, sess) perf = utils.evaluate(test_data, args, sess, tester) print("performance:") numbers = [] for k in sorted(perf.keys()): print("%s, %s" % (k, perf[k])) numbers.append("%s" % perf[k]) print(" ".join(sorted(perf.keys()))) print(" ".join(numbers))
Example #3
Source File: main.py From RAM with MIT License | 5 votes |
def main(_): print('Loading data info ...') FLAGS.word2id, FLAGS.max_sentence_len, FLAGS.max_aspect_len = get_data_info(FLAGS.train_fname, FLAGS.test_fname, FLAGS.data_info, FLAGS.pre_processed) print('Loading training data and testing data ...') train_data = read_data(FLAGS.train_fname, FLAGS.word2id, FLAGS.max_sentence_len, FLAGS.max_aspect_len, FLAGS.train_data, FLAGS.pre_processed) test_data = read_data(FLAGS.test_fname, FLAGS.word2id, FLAGS.max_sentence_len, FLAGS.max_aspect_len, FLAGS.test_data, FLAGS.pre_processed) print('Loading pre-trained word vectors ...') FLAGS.word2vec = load_word_embeddings(FLAGS.embedding_fname, FLAGS.embedding_dim, FLAGS.word2id) with tf.Session() as sess: model = RAM(FLAGS, sess) model.build_model() model.run(train_data, test_data)