本文整理汇总了Python中absl.flags.adopt_module_key_flags方法的典型用法代码示例。如果您正苦于以下问题:Python flags.adopt_module_key_flags方法的具体用法?Python flags.adopt_module_key_flags怎么用?Python flags.adopt_module_key_flags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类absl.flags
的用法示例。
在下文中一共展示了flags.adopt_module_key_flags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_key_flags_in_core
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def register_key_flags_in_core(f):
"""Defines a function in core.py, and registers its key flags.
absl uses the location of a flags.declare_key_flag() to determine the context
in which a flag is key. By making all declares in core, this allows model
main functions to call flags.adopt_module_key_flags() on core and correctly
chain key flags.
Args:
f: The function to be wrapped
Returns:
The "core-defined" version of the input function.
"""
def core_fn(*args, **kwargs):
key_flags = f(*args, **kwargs)
[flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned
return core_fn
示例2: define_movie_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def define_movie_flags():
"""Define flags for movie dataset training."""
wide_deep_run_loop.define_wide_deep_flags()
flags.DEFINE_enum(
name="dataset", default=movielens.ML_1M,
enum_values=movielens.DATASETS, case_sensitive=False,
help=flags_core.help_wrap("Dataset to be trained and evaluated."))
flags.adopt_module_key_flags(wide_deep_run_loop)
flags_core.set_defaults(data_dir="/tmp/movielens-data/",
model_dir='/tmp/movie_model',
model_type="deep",
train_epochs=50,
epochs_between_evals=5,
inter_op_parallelism_threads=0,
intra_op_parallelism_threads=0,
batch_size=256)
@flags.validator("stop_threshold",
message="stop_threshold not supported for movielens model")
def _no_stop(stop_threshold):
return stop_threshold is None
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:23,代码来源:movielens_main.py
示例3: define_wide_deep_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [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
示例4: define_wide_deep_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [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."))
示例5: define_mnist_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def define_mnist_flags():
flags_core.define_base()
flags_core.define_performance(num_parallel_calls=False)
flags_core.define_image()
flags.adopt_module_key_flags(flags_core)
flags_core.set_defaults(data_dir='/tmp/mnist_data',
model_dir='/tmp/mnist_model',
batch_size=100,
train_epochs=40)
示例6: define_nsfw_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def define_nsfw_flags():
resnet_run_loop.define_resnet_flags()
flags.adopt_module_key_flags(resnet_run_loop)
set_defaults(
data_dir='',
model_dir='',
resnet_size='50',
train_epochs=50,
epochs_between_evals=50,
batch_size=128)
示例7: define_flower_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def define_flower_flags():
resnet_run_loop.define_resnet_flags()
flags.adopt_module_key_flags(resnet_run_loop)
set_defaults(
data_dir='',
model_dir='',
resnet_size='32',
train_epochs=50,
epochs_between_evals=50,
batch_size=128)
示例8: define_resnet_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [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)
示例9: define_cifar_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def define_cifar_flags():
resnet_run_loop.define_resnet_flags()
flags.adopt_module_key_flags(resnet_run_loop)
flags_core.set_defaults(data_dir='/tmp/cifar10_data/cifar-10-batches-bin',
model_dir='/tmp/cifar10_model',
resnet_size='56',
train_epochs=182,
epochs_between_evals=10,
batch_size=128,
image_bytes_as_serving_input=False)
示例10: define_imagenet_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def define_imagenet_flags():
resnet_run_loop.define_resnet_flags(
resnet_size_choices=['18', '34', '50', '101', '152', '200'])
flags.adopt_module_key_flags(resnet_run_loop)
flags_core.set_defaults(train_epochs=90)
示例11: declare_extra_key_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def declare_extra_key_flags(flag_values=FLAGS):
"""Declares some extra key flags."""
flags.adopt_module_key_flags(module_bar, flag_values=flag_values)
示例12: test_adoptmodule_key_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def test_adoptmodule_key_flags(self):
# Check that adopt_module_key_flags raises an exception when
# called with a module name (as opposed to a module object).
self.assertRaises(flags.Error,
flags.adopt_module_key_flags,
'pyglib.app')
示例13: define_mnist_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def define_mnist_flags():
flags_core.define_base()
flags_core.define_image()
flags.adopt_module_key_flags(flags_core)
示例14: define_mnist_eager_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [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,
)
示例15: define_mnist_flags
# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import adopt_module_key_flags [as 别名]
def define_mnist_flags():
flags_core.define_base()
flags_core.define_image()
flags.adopt_module_key_flags(flags_core)
flags_core.set_defaults(data_dir='/tmp/mnist_data',
model_dir='/tmp/mnist_model',
batch_size=100,
train_epochs=40)