aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/summary
diff options
context:
space:
mode:
authorGravatar Igor Ganichev <iga@google.com>2017-12-12 21:12:14 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-12 21:16:03 -0800
commit8f19188a14b62f2612783f3ebba0cd1c9d08aba8 (patch)
tree0ed34ebf967e1b7ef6b7808dfb35394c08735160 /tensorflow/contrib/summary
parentd109bd2f3fc6a018629469a6497dfe953bf5e305 (diff)
Create global_step when recording summaries if needed
User might have not created global_step prior to using some summary method. PiperOrigin-RevId: 178857144
Diffstat (limited to 'tensorflow/contrib/summary')
-rw-r--r--tensorflow/contrib/summary/summary_ops.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tensorflow/contrib/summary/summary_ops.py b/tensorflow/contrib/summary/summary_ops.py
index 4556162bfe..ee661dfdc1 100644
--- a/tensorflow/contrib/summary/summary_ops.py
+++ b/tensorflow/contrib/summary/summary_ops.py
@@ -71,7 +71,7 @@ def should_record_summaries():
def record_summaries_every_n_global_steps(n, global_step=None):
"""Sets the should_record_summaries Tensor to true if global_step % n == 0."""
if global_step is None:
- global_step = training_util.get_global_step()
+ global_step = training_util.get_or_create_global_step()
collection_ref = ops.get_collection_ref(_SHOULD_RECORD_SUMMARIES_NAME)
old = collection_ref[:]
with ops.device("cpu:0"):
@@ -560,7 +560,7 @@ def _serialize_graph(arbitrary_graph):
def _choose_step(step):
if step is None:
- return training_util.get_global_step()
+ return training_util.get_or_create_global_step()
if not isinstance(step, ops.Tensor):
return ops.convert_to_tensor(step, dtypes.int64)
return step