def format_variables(variables, join_lines=True):
  """Takes a collection of variables and formats it as a table."""
  rows = []
  rows.append(("Variable", "Shape", "Type", "Collections", "Device"))
  var_to_collections = _get_vars_to_collections(variables)
  for var in sorted(variables, key=lambda var: var.op.name):
    if var.get_shape().is_fully_defined():
      shape = "x".join(str(dim) for dim in var.get_shape().as_list())
    else:
      shape = "undefined"
    dtype = repr(var.dtype.base_dtype).replace("tf.", "")
    coll = ", ".join(sorted(var_to_collections[var]))
    rows.append((var.op.name, shape, dtype, coll, _format_device(var)))
  return _format_table(rows, join_lines)
def format_variables ( variables , join_lines = True ) : rows = [ ] rows . append ( ( "Variable" , "Shape" , "Type" , "Collections" , "Device" ) ) var_to_collections = _get_vars_to_collections ( variables ) for var in sorted ( variables , key = lambda var : var . op . name ) : if var . get_shape ( ) . is_fully_defined ( ) : shape = "x" . join ( str ( dim ) for dim in var . get_shape ( ) . as_list ( ) ) else : shape = "undefined" dtype = repr ( var . dtype . base_dtype ) . replace ( "tf." , "" ) coll = ", " . join ( sorted ( var_to_collections [ var ] ) ) rows . append ( ( var . op . name , shape , dtype , coll , _format_device ( var ) ) ) return _format_table ( rows , join_lines )
Takes a collection of variables and formats it as a table.