#NEWLINE# def add_activation_summary( x , name = None ) : #NEWLINE# #INDENT# '\n    Add summary to graph for an activation tensor x.\n    If name is None, use x.name.\n    ' #NEWLINE# ndim = x . get_shape ( ) . ndims #NEWLINE# assert ( ndim >= 2 ) , 'Summary a scalar with histogram? Maybe use scalar instead. FIXME!' #NEWLINE# if ( name is None ) : #NEWLINE# #INDENT# name = name . name #NEWLINE# #UNINDENT# tf . histogram_summary ( ( name + '/activation' ) , x ) #NEWLINE# tf . scalar_summary ( ( name + '/activation_sparsity' ) , tf . nn . zero_fraction ( x ) )