Commit d3cb711a authored by William Chargin's avatar William Chargin Committed by TensorFlower Gardener
Browse files

Don?t create empty run directories from the TensorBoard Keras callback

Creating a summary file writer with `create_file_writer` immediately
creates an events file on disk, even if no summaries are subsequently
written. This is in contrast to TensorFlow 1.x?s `tf.summary.FileWriter`
constructor; they differ because the new version specifies a `.v2` file
suffix, and specifying a suffix causes the underlying C++ writer to
create the events file eagerly instead of lazily.

Consequently, the Keras callback creates an empty ?validation? directory
as soon as it creates the validation writer, even if the user never
provides validation data and we never emit any validation summaries.
This causes an empty ?validation? run to show up in TensorBoard, which
is suboptimal.

This patch changes the callback to initialize its writers lazily, only
when we actually write data.

Tested:
Regression test added; it passes after this change, and fails before
this change or if you change `continue` to `pass`.
PiperOrigin-RevId: 236728581
parent 7c810675
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment