本文整理匯總了Python中absl.flags.validator方法的典型用法代碼示例。如果您正苦於以下問題:Python flags.validator方法的具體用法?Python flags.validator怎麽用?Python flags.validator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類absl.flags
的用法示例。
在下文中一共展示了flags.validator方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: define_movie_flags
# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import validator [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
示例2: test_absl_validators
# 需要導入模塊: from absl import flags [as 別名]
# 或者: from absl.flags import validator [as 別名]
def test_absl_validators(self):
@flags.validator('absl_integer', flag_values=self._absl_flags)
def ensure_positive(value):
return value > 0
parser = argparse_flags.ArgumentParser(
inherited_absl_flags=self._absl_flags)
with self.assertRaises(SystemExit):
parser.parse_args(['--absl_integer', '-2'])
del ensure_positive