train_deep_g.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:nlp_code 作者: bohaohan 项目源码 文件源码
def batch_dev_step(x_batch, y_batch, writer=None):
            """
            Evaluates model on a dev set
            """
            batches = data_helpers.batch_iter(
            zip(x_batch, y_batch), FLAGS.batch_size, 1)
            for batch in batches:
                x_batch, y_batch = zip(*batch)
                feed_dict = {
                  cnn.input_x: x_batch,
                  cnn.input_y: y_batch,
                  cnn.dropout_keep_prob: 1.0
                }
                step, summaries, loss, accuracy = sess.run(
                    [global_step, dev_summary_op, cnn.loss, cnn.accuracy],
                    feed_dict)
                time_str = datetime.datetime.now().isoformat()
                print("{}: step {}, loss {:g}, acc {:g}".format(time_str, step, loss, accuracy))
                if writer:
                    writer.add_summary(summaries, step)

        # Generate batches
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号