def get_variables_with_name(name, train_only=True, printable=False):
 print ('  Get variables with %s' % name)
 t_vars = (tf.trainable_variables() if train_only else tf.all_variables())
 d_vars = [var for var in t_vars if (name in var.name)]
 if printable:
  for (idx, v) in enumerate(d_vars):
   print '  got {:3}: {:15}   {}'.format(idx, v.name, str(v.get_shape()))
 return d_vars

def get_variables_with_name ( name , train_only = True , printable = False ) : print ( '  Get variables with %s' % name ) t_vars = ( tf . trainable_variables ( ) if train_only else tf . all_variables ( ) ) d_vars = [ var for var in t_vars if ( name in var . name ) ] if printable : for ( idx , v ) in enumerate ( d_vars ) : print '  got {:3}: {:15}   {}' . format ( idx , v . name , str ( v . get_shape ( ) ) ) return d_vars
get variable list by a given name scope .