當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。