Commit 2246ab81 authored by Yuxin Wu's avatar Yuxin Wu

fix summary outside of any tower

parent c4a7f16b
...@@ -29,7 +29,8 @@ def add_activation_summary(x, name=None): ...@@ -29,7 +29,8 @@ def add_activation_summary(x, name=None):
Add summary to graph for an activation tensor x. Add summary to graph for an activation tensor x.
If name is None, use x.name. If name is None, use x.name.
""" """
if not get_current_tower_context().is_main_training_tower: ctx = get_current_tower_context()
if ctx is not None and not ctx.is_main_training_tower:
return return
ndim = x.get_shape().ndims ndim = x.get_shape().ndims
assert ndim >= 2, \ assert ndim >= 2, \
...@@ -49,7 +50,8 @@ def add_param_summary(summary_lists): ...@@ -49,7 +50,8 @@ def add_param_summary(summary_lists):
:param summary_lists: list of (regex, [list of summary type to perform]). :param summary_lists: list of (regex, [list of summary type to perform]).
Type can be 'mean', 'scalar', 'histogram', 'sparsity', 'rms' Type can be 'mean', 'scalar', 'histogram', 'sparsity', 'rms'
""" """
if not get_current_tower_context().is_main_training_tower: ctx = get_current_tower_context()
if ctx is not None and not ctx.is_main_training_tower:
return return
def perform(var, action): def perform(var, action):
ndim = var.get_shape().ndims ndim = var.get_shape().ndims
...@@ -89,7 +91,8 @@ def add_moving_summary(v, *args): ...@@ -89,7 +91,8 @@ def add_moving_summary(v, *args):
:param v: tensor or list of tensor to summary :param v: tensor or list of tensor to summary
:param args: tensors to summary :param args: tensors to summary
""" """
if not get_current_tower_context().is_main_training_tower: ctx = get_current_tower_context()
if ctx is not None and not ctx.is_main_training_tower:
return return
if not isinstance(v, list): if not isinstance(v, list):
v = [v] v = [v]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment