MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / add_param_summary

Function add_param_summary

tensorpack/tfutils/summary.py:161–195  ·  view source on GitHub ↗

Add summary ops for all trainable variables matching the regex, under a reused 'param-summary' name scope. This function is a no-op if not calling from main training tower. Args: summary_lists (list): each is (regex, [list of summary type]). Summary type is defi

(*summary_lists, **kwargs)

Source from the content-addressed store, hash-verified

159
160
161def add_param_summary(*summary_lists, **kwargs):
162 """
163 Add summary ops for all trainable variables matching the regex, under a
164 reused 'param-summary' name scope.
165 This function is a no-op if not calling from main training tower.
166
167 Args:
168 summary_lists (list): each is (regex, [list of summary type]).
169 Summary type is defined in :func:`add_tensor_summary`.
170 collections (list[str]): collections of the summary ops.
171
172 Example:
173
174 .. code-block:: python
175
176 add_param_summary(
177 ('.*/W', ['histogram', 'rms']),
178 ('.*/gamma', ['scalar']),
179 )
180 """
181 collections = kwargs.pop('collections', None)
182 assert len(kwargs) == 0, "Unknown kwargs: " + str(kwargs)
183 ctx = get_current_tower_context()
184 if ctx is not None and not ctx.is_main_training_tower:
185 return
186
187 params = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
188 with cached_name_scope('param-summary'):
189 for p in params:
190 name = p.op.name
191 for rgx, actions in summary_lists:
192 if not rgx.endswith('$'):
193 rgx = rgx + '$'
194 if re.match(rgx, name):
195 add_tensor_summary(p, actions, name=name, collections=collections)
196
197
198def add_moving_summary(*args, **kwargs):

Callers 8

build_graphMethod · 0.90
build_graphMethod · 0.90
build_graphMethod · 0.90
get_logitsMethod · 0.90
build_graphMethod · 0.85
build_graphMethod · 0.85
build_graphMethod · 0.85
get_logitsMethod · 0.85

Calls 4

cached_name_scopeFunction · 0.85
add_tensor_summaryFunction · 0.85
get_collectionMethod · 0.80

Tested by

no test coverage detected