
248 | Capítulo 9: Em Pleno Funcionamento com o TensorFlow
resumo do que você pode, então, escrever no arquivo de eventos usando o file_writer.
Veja o código atualizado:
for batch_index in range(n_batches):
X_batch, y_batch = fetch_batch(epoch, batch_index, batch_size)
if batch_index % 10 == 0:
summary_str = mse_summary.eval(feed_dict={X: X_batch, y: y_batch})
step = epoch * n_batches + batch_index
file_writer.add_summary(summary_str, step)
sess.run(training_op, feed_dict={X: X_batch, y: y_batch})
[...]
Evite registrar estatísticas de treinamento em cada etapa de treina-
mento pois isso reduzirá sua velocidade signicativamente.
Finalmente, encerre ...