(grads_and_vars)
return summaries
Add histogram summaries to gradients.

  Note: The summaries are also added to the SUMMARIES collection.

  Args:
    grads_and_vars: A list of gradient to variable pairs (tuples).

  Returns:
    The _list_ of the added summaries for grads_and_vars.
Add histogram summaries to gradients.
Add histogram summaries to gradients .
def _add_gradients_summaries(grads_and_vars):
  """Add histogram summaries to gradients.

  Note: The summaries are also added to the SUMMARIES collection.

  Args:
    grads_and_vars: A list of gradient to variable pairs (tuples).

  Returns:
    The _list_ of the added summaries for grads_and_vars.
  """
  summaries = []
  for grad, var in grads_and_vars:
    if grad is not None:
      if isinstance(grad, tf.IndexedSlices):
        grad_values = grad.values
      else:
        grad_values = grad
      summaries.append(tf.summary.histogram(var.op.name + ':gradient',
                                            grad_values))
      summaries.append(tf.summary.histogram(var.op.name + ':gradient_norm',
                                            tf.global_norm([grad_values])))
    else:
      tf.logging.info('Var %s has no gradient', var.op.name)
  return summaries
def _add_gradients_summaries ( grads_and_vars ) : summaries = [ ] for grad , var in grads_and_vars : if grad is not None : if isinstance ( grad , tf . IndexedSlices ) : grad_values = grad . values else : grad_values = grad summaries . append ( tf . summary . histogram ( var . op . name + ':gradient' , grad_values ) ) summaries . append ( tf . summary . histogram ( var . op . name + ':gradient_norm' , tf . global_norm ( [ grad_values ] ) ) ) else : tf . logging . info ( 'Var %s has no gradient' , var . op . name ) return summaries