Python absl.flags.DEFINE_bool() Examples
The following are 30
code examples of absl.flags.DEFINE_bool().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
absl.flags
, or try the search function
.
Example #1
Source File: config.py From trax with Apache License 2.0 | 6 votes |
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))
Example #2
Source File: argparse_flags_test.py From abseil-py with Apache License 2.0 | 6 votes |
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)
Example #3
Source File: download.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
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")
Example #4
Source File: data_download.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
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))
Example #5
Source File: mnist_eager.py From models with Apache License 2.0 | 5 votes |
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, )
Example #6
Source File: data_download.py From models with Apache License 2.0 | 5 votes |
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))
Example #7
Source File: mnist_eager.py From models with Apache License 2.0 | 5 votes |
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, )
Example #8
Source File: data_download.py From models with Apache License 2.0 | 5 votes |
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))
Example #9
Source File: mnist_eager.py From models with Apache License 2.0 | 5 votes |
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, )
Example #10
Source File: mnist_eager.py From models with Apache License 2.0 | 5 votes |
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, )
Example #11
Source File: mnist_eager.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
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, )
Example #12
Source File: data_download.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
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))
Example #13
Source File: config.py From trax with Apache License 2.0 | 5 votes |
def DEFINE_bool(self, name, default, *args, **kwargs): self.add_option(name, default, bool, args, kwargs)
Example #14
Source File: mnist_eager.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
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, )
Example #15
Source File: data_download.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
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))
Example #16
Source File: download.py From models with Apache License 2.0 | 5 votes |
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")
Example #17
Source File: data_download.py From models with Apache License 2.0 | 5 votes |
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))
Example #18
Source File: classifier_trainer.py From models with Apache License 2.0 | 5 votes |
def define_classifier_flags(): """Defines common flags for image classification.""" hyperparams_flags.initialize_common_flags() flags.DEFINE_string( 'data_dir', default=None, help='The location of the input data.') flags.DEFINE_string( 'mode', default=None, help='Mode to run: `train`, `eval`, `train_and_eval` or `export`.') flags.DEFINE_bool( 'run_eagerly', default=None, help='Use eager execution and disable autograph for debugging.') flags.DEFINE_string( 'model_type', default=None, help='The type of the model, e.g. EfficientNet, etc.') flags.DEFINE_string( 'dataset', default=None, help='The name of the dataset, e.g. ImageNet, etc.') flags.DEFINE_integer( 'log_steps', default=100, help='The interval of steps between logging of batch level stats.')
Example #19
Source File: mnist_main.py From models with Apache License 2.0 | 5 votes |
def define_mnist_flags(): """Define command line flags for MNIST model.""" flags_core.define_base( clean=True, num_gpu=True, train_epochs=True, epochs_between_evals=True, distribution_strategy=True) flags_core.define_device() flags_core.define_distribution() flags.DEFINE_bool('download', False, 'Whether to download data to `--data_dir`.') FLAGS.set_default('batch_size', 1024)
Example #20
Source File: download.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
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")
Example #21
Source File: mnist_eager.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
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, )
Example #22
Source File: run_saved_model.py From delta with Apache License 2.0 | 5 votes |
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'])
Example #23
Source File: tpu_executor.py From tpu_models with Apache License 2.0 | 5 votes |
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')
Example #24
Source File: resnet_run_loop.py From nsfw with Apache License 2.0 | 5 votes |
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)
Example #25
Source File: main.py From delta with Apache License 2.0 | 5 votes |
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')
Example #26
Source File: main.py From delta with Apache License 2.0 | 5 votes |
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!")
Example #27
Source File: run_saved_model.py From delta with Apache License 2.0 | 5 votes |
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'])
Example #28
Source File: main.py From delta with Apache License 2.0 | 5 votes |
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!")
Example #29
Source File: run_saved_model.py From delta with Apache License 2.0 | 5 votes |
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'])
Example #30
Source File: run_saved_model.py From delta with Apache License 2.0 | 5 votes |
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'])