MCPcopy
hub / github.com/dennybritz/cnn-text-classification-tf / train_step

Function train_step

train.py:142–156  ·  view source on GitHub ↗

A single training step

(x_batch, y_batch)

Source from the content-addressed store, hash-verified

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 """

Callers 1

trainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected