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


Python flags.DEFINE_boolean方法代码示例

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


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

示例1: define_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def define_flags(specs=None):
  """Define a command line flag for each ParamSpec in flags.param_specs."""
  specs = specs or param_specs
  define_flag = {
      'boolean': absl_flags.DEFINE_boolean,
      'float': absl_flags.DEFINE_float,
      'integer': absl_flags.DEFINE_integer,
      'string': absl_flags.DEFINE_string,
      'enum': absl_flags.DEFINE_enum,
      'list': absl_flags.DEFINE_list
  }
  for name, param_spec in six.iteritems(specs):
    if param_spec.flag_type not in define_flag:
      raise ValueError('Unknown flag_type %s' % param_spec.flag_type)
    else:
      define_flag[param_spec.flag_type](name, param_spec.default_value,
                                        help=param_spec.description,
                                        **param_spec.kwargs) 
开发者ID:tensorflow,项目名称:benchmarks,代码行数:20,代码来源:flags.py

示例2: _define_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def _define_flags(options):
  for option in _filter_options(options):
    name, type_, default_ = option[:3]
    if type_ == 'boolean':
      flags.DEFINE_boolean(name, default_, '')
    elif type_ == 'integer':
      flags.DEFINE_integer(name, default_, '')
    elif type_ == 'float':
      flags.DEFINE_float(name, default_, '')
    elif type_ == 'string':
      flags.DEFINE_string(name, default_, '')
    elif type_ == 'list_of_ints':
      flags.DEFINE_string(name, default_, '')
    else:
      assert 'Unexpected option type %s' % type_


# Define command-line flags for all options (unless `internal`). 
开发者ID:deepmind,项目名称:lamb,代码行数:20,代码来源:lamb_flags.py

示例3: duplicate_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def duplicate_flags(flagnames=None):
  """Returns a new FlagValues object with the requested flagnames.

  Used to test DuplicateFlagError detection.

  Args:
    flagnames: str, A list of flag names to create.

  Returns:
    A FlagValues object with one boolean flag for each name in flagnames.
  """
  flag_values = flags.FlagValues()
  for name in flagnames:
    flags.DEFINE_boolean(name, False, 'Flag named %s' % (name,),
                         flag_values=flag_values)
  return flag_values 
开发者ID:abseil,项目名称:abseil-py,代码行数:18,代码来源:module_foo.py

示例4: define_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def define_flags(flag_values=FLAGS):
  """Defines some flags.

  Args:
    flag_values: The FlagValues object we want to register the flags
      with.
  """
  # The 'tmod_bar_' prefix (short for 'test_module_bar') ensures there
  # is no name clash with the existing flags.
  flags.DEFINE_boolean('tmod_bar_x', True, 'Boolean flag.',
                       flag_values=flag_values)
  flags.DEFINE_string('tmod_bar_y', 'default', 'String flag.',
                      flag_values=flag_values)
  flags.DEFINE_boolean('tmod_bar_z', False,
                       'Another boolean flag from module bar.',
                       flag_values=flag_values)
  flags.DEFINE_integer('tmod_bar_t', 4, 'Sample int flag.',
                       flag_values=flag_values)
  flags.DEFINE_integer('tmod_bar_u', 5, 'Sample int flag.',
                       flag_values=flag_values)
  flags.DEFINE_integer('tmod_bar_v', 6, 'Sample int flag.',
                       flag_values=flag_values) 
开发者ID:abseil,项目名称:abseil-py,代码行数:24,代码来源:module_bar.py

示例5: define_wide_deep_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def define_wide_deep_flags():
  """Add supervised learning flags, as well as wide-deep model type."""
  flags_core.define_base(clean=True, train_epochs=True,
                         epochs_between_evals=True)
  flags_core.define_benchmark()
  flags_core.define_performance(
      num_parallel_calls=False, inter_op=True, intra_op=True,
      synthetic_data=False, max_train_steps=False, dtype=False,
      all_reduce_alg=False)

  flags.adopt_module_key_flags(flags_core)

  flags.DEFINE_enum(
      name="model_type", short_name="mt", default="wide_deep",
      enum_values=['wide', 'deep', 'wide_deep'],
      help="Select model topology.")
  flags.DEFINE_boolean(
      name="download_if_missing", default=True, help=flags_core.help_wrap(
          "Download data to data_dir if it is not already present.")) 
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:21,代码来源:wide_deep_run_loop.py

示例6: define_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def define_flags():
  """Define a command line flag for each ParamSpec in flags.param_specs."""
  define_flag = {
      'boolean': absl_flags.DEFINE_boolean,
      'float': absl_flags.DEFINE_float,
      'integer': absl_flags.DEFINE_integer,
      'string': absl_flags.DEFINE_string,
      'enum': absl_flags.DEFINE_enum,
      'list': absl_flags.DEFINE_list
  }
  for name, param_spec in six.iteritems(param_specs):
    if param_spec.flag_type not in define_flag:
      raise ValueError('Unknown flag_type %s' % param_spec.flag_type)
    else:
      define_flag[param_spec.flag_type](name, param_spec.default_value,
                                        help=param_spec.description,
                                        **param_spec.kwargs) 
开发者ID:HewlettPackard,项目名称:dlcookbook-dlbs,代码行数:19,代码来源:flags.py

示例7: define_wide_deep_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def define_wide_deep_flags():
  """Add supervised learning flags, as well as wide-deep model type."""
  flags_core.define_base()
  flags_core.define_benchmark()
  flags_core.define_performance(
      num_parallel_calls=False, inter_op=True, intra_op=True,
      synthetic_data=False, max_train_steps=False, dtype=False,
      all_reduce_alg=False)

  flags.adopt_module_key_flags(flags_core)

  flags.DEFINE_enum(
      name="model_type", short_name="mt", default="wide_deep",
      enum_values=['wide', 'deep', 'wide_deep'],
      help="Select model topology.")
  flags.DEFINE_boolean(
      name="download_if_missing", default=True, help=flags_core.help_wrap(
          "Download data to data_dir if it is not already present.")) 
开发者ID:generalized-iou,项目名称:g-tensorflow-models,代码行数:20,代码来源:wide_deep_run_loop.py

示例8: DEFINE_boolean

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def DEFINE_boolean(name, default, help):  # pylint: disable=invalid-name,redefined-builtin
  param_specs[name] = ParamSpec('boolean', default, help, {}) 
开发者ID:tensorflow,项目名称:benchmarks,代码行数:4,代码来源:flags.py

示例9: define_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def define_flags():
    """Define a command line flag for each ParamSpec in _DEFAULT_PARAMS."""
    define_flag = {
        'boolean': flags.DEFINE_boolean,
        'float': flags.DEFINE_float,
        'integer': flags.DEFINE_integer,
        'string': flags.DEFINE_string,
    }
    for name, param_spec in six.iteritems(_DEFAULT_PARAMS):
        if param_spec.flag_type not in define_flag:
            raise ValueError('Unknown flag_type %s' % param_spec.flag_type)
        else:
            define_flag[param_spec.flag_type](name, param_spec.default_value,
                                              param_spec.description)
            flags.declare_key_flag(name) 
开发者ID:snuspl,项目名称:parallax,代码行数:17,代码来源:benchmark_cnn.py

示例10: define_resnet_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [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

示例11: define_keras_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def define_keras_flags():
  flags.DEFINE_boolean(name='enable_eager', default=False, help='Enable eager?')
  flags.DEFINE_boolean(name='skip_eval', default=False, help='Skip evaluation?')
  flags.DEFINE_integer(
      name='train_steps', default=None,
      help='The number of steps to run for training. If it is larger than '
      '# batches per epoch, then use # batches per epoch. When this flag is '
      'set, only one epoch is going to run for training.')
  flags.DEFINE_integer(
      name='log_steps', default=100,
      help='For every log_steps, we log the timing information such as '
      'examples per second. Besides, for every log_steps, we store the '
      'timestamp of a batch end.') 
开发者ID:GoogleCloudPlatform,项目名称:ml-on-gcp,代码行数:15,代码来源:keras_common.py

示例12: define_flags

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def define_flags(flag_values=FLAGS):
  """Defines a few flags."""
  module_bar.define_flags(flag_values=flag_values)
  # The 'tmod_foo_' prefix (short for 'test_module_foo') ensures that we
  # have no name clash with existing flags.
  flags.DEFINE_boolean('tmod_foo_bool', True, 'Boolean flag from module foo.',
                       flag_values=flag_values)
  flags.DEFINE_string('tmod_foo_str', 'default', 'String flag.',
                      flag_values=flag_values)
  flags.DEFINE_integer('tmod_foo_int', 3, 'Sample int flag.',
                       flag_values=flag_values) 
开发者ID:abseil,项目名称:abseil-py,代码行数:13,代码来源:module_foo.py

示例13: setUp

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def setUp(self):
    self.flag_values = flags.FlagValues()
    flags.DEFINE_string('unittest_message1', 'Foo!', 'You Add Here.',
                        flag_values=self.flag_values)
    flags.DEFINE_string('unittest_message2', 'Bar!', 'Hello, Sailor!',
                        flag_values=self.flag_values)
    flags.DEFINE_boolean('unittest_boolflag', 0, 'Some Boolean thing',
                         flag_values=self.flag_values)
    flags.DEFINE_integer('unittest_number', 12345, 'Some integer',
                         lower_bound=0, flag_values=self.flag_values)
    flags.DEFINE_list('UnitTestList', '1,2,3', 'Some list',
                      flag_values=self.flag_values)
    self.tmp_path = None
    self.flag_values.mark_as_parsed() 
开发者ID:abseil,项目名称:abseil-py,代码行数:16,代码来源:flags_test.py

示例14: test_find_module_defining_flag_passing_module_name

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def test_find_module_defining_flag_passing_module_name(self):
    my_flags = flags.FlagValues()
    module_name = sys.__name__  # Must use an existing module.
    flags.DEFINE_boolean('flag_name', True,
                         'Flag with a different module name.',
                         flag_values=my_flags,
                         module_name=module_name)
    self.assertEqual(module_name,
                     my_flags.find_module_defining_flag('flag_name')) 
开发者ID:abseil,项目名称:abseil-py,代码行数:11,代码来源:flags_test.py

示例15: test_find_module_id_defining_flag_passing_module_name

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import DEFINE_boolean [as 别名]
def test_find_module_id_defining_flag_passing_module_name(self):
    my_flags = flags.FlagValues()
    module_name = sys.__name__  # Must use an existing module.
    flags.DEFINE_boolean('flag_name', True,
                         'Flag with a different module name.',
                         flag_values=my_flags,
                         module_name=module_name)
    self.assertEqual(id(sys),
                     my_flags.find_module_id_defining_flag('flag_name')) 
开发者ID:abseil,项目名称:abseil-py,代码行数:11,代码来源:flags_test.py


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