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


Python flags.adopt_module_key_flags方法代碼示例

本文整理匯總了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 
開發者ID:IntelAI,項目名稱:models,代碼行數:21,代碼來源:core.py

示例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.")) 
開發者ID:generalized-iou,項目名稱:g-tensorflow-models,代碼行數:20,代碼來源:wide_deep_run_loop.py

示例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) 
開發者ID:GoogleCloudPlatform,項目名稱:cloudml-samples,代碼行數:11,代碼來源:model.py

示例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) 
開發者ID:rockyzhengwu,項目名稱:nsfw,代碼行數:13,代碼來源:nsfw_main_finetune.py

示例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) 
開發者ID:rockyzhengwu,項目名稱:nsfw,代碼行數:13,代碼來源:nsfw_scratch.py

示例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) 
開發者ID:rockyzhengwu,項目名稱:nsfw,代碼行數:37,代碼來源:resnet_run_loop.py

示例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) 
開發者ID:GoogleCloudPlatform,項目名稱:ml-on-gcp,代碼行數:12,代碼來源:cifar10_main.py

示例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) 
開發者ID:GoogleCloudPlatform,項目名稱:ml-on-gcp,代碼行數:7,代碼來源:imagenet_main.py

示例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) 
開發者ID:abseil,項目名稱:abseil-py,代碼行數:5,代碼來源:module_foo.py

示例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') 
開發者ID:abseil,項目名稱:abseil-py,代碼行數:8,代碼來源:flags_test.py

示例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) 
開發者ID:PipelineAI,項目名稱:models,代碼行數:6,代碼來源:pipeline_train.py

示例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,
  ) 
開發者ID:PipelineAI,項目名稱:models,代碼行數:32,代碼來源:mnist_eager.py

示例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) 
開發者ID:PipelineAI,項目名稱:models,代碼行數:10,代碼來源:mnist.py


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