本文整理匯總了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)
示例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`).
示例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
示例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)
示例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)
示例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."))
示例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, {})
示例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)
示例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)
示例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.')
示例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)
示例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()
示例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'))
示例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'))