本文整理汇总了Python中utils.read_data方法的典型用法代码示例。如果您正苦于以下问题:Python utils.read_data方法的具体用法?Python utils.read_data怎么用?Python utils.read_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils.read_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import utils [as 别名]
# 或者: from utils import read_data [as 别名]
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))
示例2: main
# 需要导入模块: import utils [as 别名]
# 或者: from utils import read_data [as 别名]
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))
示例3: main
# 需要导入模块: import utils [as 别名]
# 或者: from utils import read_data [as 别名]
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)