本文整理汇总了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))
示例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)
示例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)
示例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)
示例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')
示例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')
示例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!")
示例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!")
示例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'])
示例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,
)
示例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))
示例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")