當前位置: 首頁>>代碼示例>>Python>>正文


Python flags.DEFINE_bool方法代碼示例

本文整理匯總了Python中absl.flags.DEFINE_bool方法的典型用法代碼示例。如果您正苦於以下問題:Python flags.DEFINE_bool方法的具體用法?Python flags.DEFINE_bool怎麽用?Python flags.DEFINE_bool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在absl.flags的用法示例。


在下文中一共展示了flags.DEFINE_bool方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: config_with_absl

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def config_with_absl(self):
    # Run this before calling `app.run(main)` etc
    import absl.flags as absl_FLAGS
    from absl import app, flags as absl_flags

    self.use_absl = True
    self.absl_flags = absl_flags
    absl_defs = { bool: absl_flags.DEFINE_bool,
                  int:  absl_flags.DEFINE_integer,
                  str:  absl_flags.DEFINE_string,
                  'enum': absl_flags.DEFINE_enum }

    for name, val in self.values.items():
      flag_type, meta_args, meta_kwargs = self.meta[name]
      absl_defs[flag_type](name, val, *meta_args, **meta_kwargs)

    app.call_after_init(lambda: self.complete_absl_config(absl_flags)) 
開發者ID:google,項目名稱:trax,代碼行數:19,代碼來源:config.py

示例2: setUp

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def setUp(self):
    self._absl_flags = flags.FlagValues()
    flags.DEFINE_bool(
        'absl_bool', None, 'help for --absl_bool.',
        short_name='b', flag_values=self._absl_flags)
    # Add a boolean flag that starts with "no", to verify it can correctly
    # handle the "no" prefixes in boolean flags.
    flags.DEFINE_bool(
        'notice', None, 'help for --notice.',
        flag_values=self._absl_flags)
    flags.DEFINE_string(
        'absl_string', 'default', 'help for --absl_string=%.',
        short_name='s', flag_values=self._absl_flags)
    flags.DEFINE_integer(
        'absl_integer', 1, 'help for --absl_integer.',
        flag_values=self._absl_flags)
    flags.DEFINE_float(
        'absl_float', 1, 'help for --absl_integer.',
        flag_values=self._absl_flags)
    flags.DEFINE_enum(
        'absl_enum', 'apple', ['apple', 'orange'], 'help for --absl_enum.',
        flag_values=self._absl_flags) 
開發者ID:abseil,項目名稱:abseil-py,代碼行數:24,代碼來源:argparse_flags_test.py

示例3: DEFINE_bool

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def DEFINE_bool(self, name, default, *args, **kwargs):
    self.add_option(name, default, bool, args, kwargs) 
開發者ID:google,項目名稱:trax,代碼行數:4,代碼來源:config.py

示例4: define_resnet_flags

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def define_resnet_flags(resnet_size_choices=None):
  """Add flags and validators for ResNet."""
  flags_core.define_base()
  flags_core.define_performance(num_parallel_calls=False)
  flags_core.define_image()
  flags_core.define_benchmark()
  flags.adopt_module_key_flags(flags_core)

  flags.DEFINE_enum(
      name='resnet_version', short_name='rv', default='1',
      enum_values=['1', '2'],
      help=flags_core.help_wrap(
          'Version of ResNet. (1 or 2) See README.md for details.'))
  flags.DEFINE_bool(
      name='fine_tune', short_name='ft', default=False,
      help=flags_core.help_wrap(
          'If True do not train any parameters except for the final layer.'))
  flags.DEFINE_string(
      name='pretrained_model_checkpoint_path', short_name='pmcp', default=None,
      help=flags_core.help_wrap(
          'If not None initialize all the network except the final layer with '
          'these values'))
  flags.DEFINE_boolean(
      name='eval_only', default=False,
      help=flags_core.help_wrap('Skip training and only perform evaluation on '
                                'the latest checkpoint.'))

  choice_kwargs = dict(
      name='resnet_size', short_name='rs', default='50',
      help=flags_core.help_wrap('The size of the ResNet model to use.'))

  if resnet_size_choices is None:
    flags.DEFINE_string(**choice_kwargs)
  else:
    flags.DEFINE_enum(enum_values=resnet_size_choices, **choice_kwargs) 
開發者ID:rockyzhengwu,項目名稱:nsfw,代碼行數:37,代碼來源:resnet_run_loop.py

示例5: define_tpu_flags

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def define_tpu_flags():
  """Define common flags for TPU."""
  flags.DEFINE_string(
      'tpu',
      default=None,
      help='The Cloud TPU to use for training. This should be either the name '
      'used when creating the Cloud TPU, or a grpc://ip.address.of.tpu:8470 '
      'url.')
  flags.DEFINE_string(
      'gcp_project',
      default=None,
      help='Project name for the Cloud TPU-enabled project. If not specified, we '
      'will attempt to automatically detect the GCE project from metadata.')
  flags.DEFINE_string(
      'tpu_zone',
      default=None,
      help='GCE zone where the Cloud TPU is located in. If not specified, we '
      'will attempt to automatically detect the GCE project from metadata.')
  flags.DEFINE_integer(
      'num_cores', default=8, help='Number of TPU cores for training')
  flags.DEFINE_string(
      'eval_master',
      default='',
      help='GRPC URL of the eval master. Set to an appropiate value when running '
      'on CPU/GPU')
  flags.DEFINE_bool('use_tpu', True, 'Use TPUs rather than CPUs')
  flags.DEFINE_multi_integer(
      'input_partition_dims', [1],
      'A list that describes the partition dims for all the tensors.')
  flags.DEFINE_integer('iterations_per_loop', 8,
                       'Number of iterations per TPU training loop') 
開發者ID:artyompal,項目名稱:tpu_models,代碼行數:33,代碼來源:tpu_executor.py

示例6: define_flags

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def define_flags():
  """Define flags for the program."""
  flags.DEFINE_string('config', '', 'config path')
  flags.DEFINE_string(
      'cmd', '',
      'train, eval, infer, train_and_eval, export_model, gen_feat, gen_cmvn, build')
  flags.DEFINE_bool('test', 'False', 'run all unit test')
  flags.DEFINE_bool('dry_run', 'False', 'dry run, to no save file')
  flags.DEFINE_bool('log_debug', 'False', 'logging debug switch')
  flags.DEFINE_string('name', '', 'Data set name')
  flags.DEFINE_string('dir', '', 'Data set directory') 
開發者ID:didi,項目名稱:delta,代碼行數:13,代碼來源:main.py

示例7: entry

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def entry():
  define_flags()
  flags.DEFINE_bool('only_nlp', 'False', 'only use nlp modules')
  logging.info("Deep Language Technology Platform start...")
  app.run(main)
  logging.info("OK. Done!") 
開發者ID:didi,項目名稱:delta,代碼行數:8,代碼來源:main.py

示例8: nlp_entry

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def nlp_entry():
  define_flags()
  flags.DEFINE_bool('only_nlp', 'True', 'only use nlp modules')
  logging.info("Deep Language Technology Platform start...")
  app.run(main)
  logging.info("OK. Done!") 
開發者ID:didi,項目名稱:delta,代碼行數:8,代碼來源:main.py

示例9: define_flags

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def define_flags():
  ''' define flags for evaluator'''
  # The GPU devices which are visible for current process
  flags.DEFINE_string('gpu', '', 'same to CUDA_VISIBLE_DEVICES')
  flags.DEFINE_string('config', None, help='path to yaml config file')
  flags.DEFINE_enum('mode', 'eval', ['eval', 'infer', 'eval_and_infer'],
                    'eval or infer')
  flags.DEFINE_bool('debug', False, 'debug mode')
  # https://github.com/abseil/abseil-py/blob/master/absl/flags/_validators.py#L330
  flags.mark_flags_as_required(['config', 'mode']) 
開發者ID:didi,項目名稱:delta,代碼行數:12,代碼來源:run_saved_model.py

示例10: define_mnist_eager_flags

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def define_mnist_eager_flags():
  """Defined flags and defaults for MNIST in eager mode."""
  flags_core.define_base_eager()
  flags_core.define_image()
  flags.adopt_module_key_flags(flags_core)

  flags.DEFINE_integer(
      name='log_interval', short_name='li', default=10,
      help=flags_core.help_wrap('batches between logging training status'))

  flags.DEFINE_string(
      name='output_dir', short_name='od', default=None,
      help=flags_core.help_wrap('Directory to write TensorBoard summaries'))

  flags.DEFINE_float(name='learning_rate', short_name='lr', default=0.01,
                     help=flags_core.help_wrap('Learning rate.'))

  flags.DEFINE_float(name='momentum', short_name='m', default=0.5,
                     help=flags_core.help_wrap('SGD momentum.'))

  flags.DEFINE_bool(name='no_gpu', short_name='nogpu', default=False,
                    help=flags_core.help_wrap(
                        'disables GPU usage even if a GPU is available'))

  flags_core.set_defaults(
      data_dir='/tmp/tensorflow/mnist/input_data',
      model_dir='/tmp/tensorflow/mnist/checkpoints/',
      batch_size=100,
      train_epochs=10,
  ) 
開發者ID:PipelineAI,項目名稱:models,代碼行數:32,代碼來源:mnist_eager.py

示例11: define_data_download_flags

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def define_data_download_flags():
  """Add flags specifying data download arguments."""
  flags.DEFINE_string(
      name="data_dir", short_name="dd", default="/tmp/translate_ende",
      help=flags_core.help_wrap(
          "Directory for where the translate_ende_wmt32k dataset is saved."))
  flags.DEFINE_string(
      name="raw_dir", short_name="rd", default="/tmp/translate_ende_raw",
      help=flags_core.help_wrap(
          "Path where the raw data will be downloaded and extracted."))
  flags.DEFINE_bool(
      name="search", default=False,
      help=flags_core.help_wrap(
          "If set, use binary search to find the vocabulary set with size"
          "closest to the target size (%d)." % _TARGET_VOCAB_SIZE)) 
開發者ID:PipelineAI,項目名稱:models,代碼行數:17,代碼來源:data_download.py

示例12: define_mnist_eager_flags

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def define_mnist_eager_flags():
  """Defined flags and defaults for MNIST in eager mode."""
  flags_core.define_base_eager(clean=True, train_epochs=True)
  flags_core.define_image()
  flags.adopt_module_key_flags(flags_core)

  flags.DEFINE_integer(
      name='log_interval', short_name='li', default=10,
      help=flags_core.help_wrap('batches between logging training status'))

  flags.DEFINE_string(
      name='output_dir', short_name='od', default=None,
      help=flags_core.help_wrap('Directory to write TensorBoard summaries'))

  flags.DEFINE_float(name='learning_rate', short_name='lr', default=0.01,
                     help=flags_core.help_wrap('Learning rate.'))

  flags.DEFINE_float(name='momentum', short_name='m', default=0.5,
                     help=flags_core.help_wrap('SGD momentum.'))

  flags.DEFINE_bool(name='no_gpu', short_name='nogpu', default=False,
                    help=flags_core.help_wrap(
                        'disables GPU usage even if a GPU is available'))

  flags_core.set_defaults(
      data_dir='/tmp/tensorflow/mnist/input_data',
      model_dir='/tmp/tensorflow/mnist/checkpoints/',
      batch_size=100,
      train_epochs=10,
  ) 
開發者ID:ShivangShekhar,項目名稱:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代碼行數:32,代碼來源:mnist_eager.py

示例13: define_data_download_flags

# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import DEFINE_bool [as 別名]
def define_data_download_flags():
  """Define flags for data downloading."""
  absl_flags.DEFINE_string(
      "data_dir", "/tmp/librispeech_data",
      "Directory to download data and extract the tarball")
  absl_flags.DEFINE_bool("train_only", False,
                         "If true, only download the training set")
  absl_flags.DEFINE_bool("dev_only", False,
                         "If true, only download the dev set")
  absl_flags.DEFINE_bool("test_only", False,
                         "If true, only download the test set") 
開發者ID:generalized-iou,項目名稱:g-tensorflow-models,代碼行數:13,代碼來源:download.py


注:本文中的absl.flags.DEFINE_bool方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。