def train_step(x_batch, y_batch):
"""
A single training step
"""
feed_dict = {
lstm.input_x: x_batch,
lstm.input_y: y_batch,
lstm.dropout_keep_prob: FLAGS.dropout_keep_prob,
lstm.batch_size: FLAGS.batch_size,
lstm.real_len: real_len(x_batch)
}
_, step, summaries, loss, accuracy = sess.run(
[train_op, global_step, train_summary_op, lstm.loss, lstm.accuracy],
feed_dict)
lstm.W = tf.clip_by_norm(lstm.W, 3)
time_str = datetime.datetime.now().isoformat()
print("TRAIN step {}, loss {:g}, acc {:g}".format(step, loss, accuracy))
train_summary_writer.add_summary(summaries, step)
评论列表
文章目录