A single training step
(x_batch, y_batch)
| 140 | sess.run(tf.global_variables_initializer()) |
| 141 | |
| 142 | def train_step(x_batch, y_batch): |
| 143 | """ |
| 144 | A single training step |
| 145 | """ |
| 146 | feed_dict = { |
| 147 | cnn.input_x: x_batch, |
| 148 | cnn.input_y: y_batch, |
| 149 | cnn.dropout_keep_prob: FLAGS.dropout_keep_prob |
| 150 | } |
| 151 | _, step, summaries, loss, accuracy = sess.run( |
| 152 | [train_op, global_step, train_summary_op, cnn.loss, cnn.accuracy], |
| 153 | feed_dict) |
| 154 | time_str = datetime.datetime.now().isoformat() |
| 155 | print("{}: step {}, loss {:g}, acc {:g}".format(time_str, step, loss, accuracy)) |
| 156 | train_summary_writer.add_summary(summaries, step) |
| 157 | |
| 158 | def dev_step(x_batch, y_batch, writer=None): |
| 159 | """ |