@@ -78,16 +78,21 @@ def __init__(self):
78
78
def _should_record_summaries_internal (default_state ):
79
79
"""Returns boolean Tensor if summaries should/shouldn't be recorded.
80
80
81
- Now the summary condition is decided by logical "and" of two conditions:
82
- ctx.summary_recording and ctx.summary_recording_distribution_strategy. The
83
- former one is usually set by user, and the latter one is controlled by
84
- DistributionStrategy (tf.distribute.ReplicaContext).
81
+ Now the summary condition is decided by logical "and" of below conditions:
82
+ First, summary writer must be set. Given this constraint is met,
83
+ ctx.summary_recording and ctx.summary_recording_distribution_strategy.
84
+ The former one is usually set by user, and the latter one is controlled
85
+ by DistributionStrategy (tf.distribute.ReplicaContext).
85
86
86
87
Args:
87
- default_state: can be True or False. The default summary behavior when user
88
- does not specify ctx.summary_recording and
89
- ctx.summary_recording_distribution_strategy is True.
88
+ default_state: can be True or False. The default summary behavior when
89
+ summary writer is set and the user does not specify
90
+ ctx.summary_recording and ctx.summary_recording_distribution_strategy
91
+ is True.
90
92
"""
93
+ if _summary_state .writer is None :
94
+ return constant_op .constant (False )
95
+
91
96
resolve = lambda x : x () if callable (x ) else x
92
97
cond_distributed = resolve (_summary_state .is_recording_distribution_strategy )
93
98
cond = resolve (_summary_state .is_recording )
0 commit comments