当前位置: 首页>>代码示例>>Python>>正文


Python flags.BooleanParser方法代码示例

本文整理汇总了Python中tensorflow.python.platform.flags.BooleanParser方法的典型用法代码示例。如果您正苦于以下问题:Python flags.BooleanParser方法的具体用法?Python flags.BooleanParser怎么用?Python flags.BooleanParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.python.platform.flags的用法示例。


在下文中一共展示了flags.BooleanParser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_numpy_printoption

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import BooleanParser [as 别名]
def parse_numpy_printoption(kv_str):
  """Sets a single numpy printoption from a string of the form 'x=y'.

  See documentation on numpy.set_printoptions() for details about what values
  x and y can take. x can be any option listed there other than 'formatter'.

  Args:
    kv_str: A string of the form 'x=y', such as 'threshold=100000'

  Raises:
    argparse.ArgumentTypeError: If the string couldn't be used to set any
        nump printoption.
  """
  k_v_str = kv_str.split("=", 1)
  if len(k_v_str) != 2 or not k_v_str[0]:
    raise argparse.ArgumentTypeError("'%s' is not in the form k=v." % kv_str)
  k, v_str = k_v_str
  printoptions = np.get_printoptions()
  if k not in printoptions:
    raise argparse.ArgumentTypeError("'%s' is not a valid printoption." % k)
  v_type = type(printoptions[k])
  if v_type is type(None):
    raise argparse.ArgumentTypeError(
        "Setting '%s' from the command line is not supported." % k)
  try:
    v = (v_type(v_str) if v_type is not bool
         else flags.BooleanParser().parse(v_str))
  except ValueError as e:
    raise argparse.ArgumentTypeError(e.message)
  np.set_printoptions(**{k: v}) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:32,代码来源:inspect_checkpoint.py

示例2: parse_numpy_printoption

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import BooleanParser [as 别名]
def parse_numpy_printoption(kv_str):
    """Sets a single numpy printoption from a string of the form 'x=y'.

    See documentation on numpy.set_printoptions() for details about what values
    x and y can take. x can be any option listed there other than 'formatter'.

    Args:
        kv_str: A string of the form 'x=y', such as 'threshold=100000'

    Raises:
        argparse.ArgumentTypeError: If the string couldn't be used to set any
                nump printoption.
    """
    k_v_str = kv_str.split("=", 1)
    if len(k_v_str) != 2 or not k_v_str[0]:
        raise argparse.ArgumentTypeError("'%s' is not in the form k=v." % kv_str)
    k, v_str = k_v_str
    printoptions = np.get_printoptions()
    if k not in printoptions:
        raise argparse.ArgumentTypeError("'%s' is not a valid printoption." % k)
    v_type = type(printoptions[k])
    if v_type is type(None):
        raise argparse.ArgumentTypeError(
                "Setting '%s' from the command line is not supported." % k)
    try:
        v = (v_type(v_str) if v_type is not bool
             else flags.BooleanParser().Parse(v_str))
    except ValueError as e:
        raise argparse.ArgumentTypeError(e.message)
    np.set_printoptions(**{k: v}) 
开发者ID:Zehaos,项目名称:MobileNet,代码行数:32,代码来源:inspect_checkpoint.py

示例3: parse_numpy_printoption

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import BooleanParser [as 别名]
def parse_numpy_printoption(kv_str):
  """Sets a single numpy printoption from a string of the form 'x=y'.
  See documentation on numpy.set_printoptions() for details about what values
  x and y can take. x can be any option listed there other than 'formatter'.
  Args:
    kv_str: A string of the form 'x=y', such as 'threshold=100000'
  Raises:
    argparse.ArgumentTypeError: If the string couldn't be used to set any
        nump printoption.
  """
  k_v_str = kv_str.split("=", 1)
  if len(k_v_str) != 2 or not k_v_str[0]:
    raise argparse.ArgumentTypeError("'%s' is not in the form k=v." % kv_str)
  k, v_str = k_v_str
  printoptions = np.get_printoptions()
  if k not in printoptions:
    raise argparse.ArgumentTypeError("'%s' is not a valid printoption." % k)
  v_type = type(printoptions[k])
  if v_type is type(None):
    raise argparse.ArgumentTypeError(
        "Setting '%s' from the command line is not supported." % k)
  try:
    v = (v_type(v_str) if v_type is not bool
         else flags.BooleanParser().parse(v_str))
  except ValueError as e:
    raise argparse.ArgumentTypeError(e.message)
  np.set_printoptions(**{k: v}) 
开发者ID:zhaocq-nlp,项目名称:NJUNMT-tf,代码行数:29,代码来源:inspect_cp.py


注:本文中的tensorflow.python.platform.flags.BooleanParser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。