如何解决测试时间越来越长的问题

时间:2019-04-28 03:30:12

标签: python tensorflow

我正在使用tensorflow解决文本分类问题。
问题是测试时间越来越长。
例如,在1个时代需要20秒。
但是在2时23秒,3时25秒,4时28秒...
(培训时间不会更长!)
您可以在下面查看我的代码吗?

test = BatchGenerator(dataset_path = test_path,
                      batch_size = config.batch,
                      max_length = config.strmaxlen)

pred_label_lst = []
true_label_lst = []
for review, label in test:
    review = process(review, config.strmaxlen) # decompose sentence and adjust a particular length(config.strmaxlen)
    pred_label, true_label = sess.run([model.predictions, tf.argmax(y, 1)],
                                      feed_dict = {x: review, y: label, keep_prob: 1.}
    pred_label_lst.extend(pred_label)
    true_label_lst.extend(true_label)

0 个答案:

没有答案