本文整理汇总了Python中tensorflow.python.platform.app.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run
def run(main=None, argv=None):
"""Runs the program with an optional main function and argv list.
The program will run with eager execution enabled.
Example:
```python
import tensorflow as tf
# Import subject to future changes:
from tensorflow.contrib.eager.python import tfe
def main(_):
u = tf.constant(6.0)
v = tf.constant(7.0)
print(u * v)
if __name__ == "__main__":
tfe.run()
```
Args:
main: the main function to run.
argv: the arguments to pass to it.
"""
enable_eager_execution()
app.run(main, argv)
开发者ID:allanbian1017,项目名称:tensorflow,代码行数:26,代码来源:context.py
示例2: run
def run(main=None, argv=None):
"""Runs the program with an optional 'main' function and 'argv' list.
The program will run with eager execution enabled.
Args:
main: the main function to run
argv: the arguments to pass to it
"""
enable_eager_execution()
app.run(main, argv)
开发者ID:chdinh,项目名称:tensorflow,代码行数:11,代码来源:context.py
示例3: benchmarks_main
def benchmarks_main(true_main):
"""Run benchmarks as declared in args.
Args:
true_main: True main function to run if benchmarks are not requested.
"""
argv = sys.argv
found_arg = [arg for arg in argv if arg.startswith("--benchmarks=") or arg.startswith("-benchmarks=")]
if found_arg:
# Remove --benchmarks arg from sys.argv
argv.remove(found_arg[0])
regex = found_arg[0].split("=")[1]
app.run(lambda _: _run_benchmarks(regex))
else:
true_main()
开发者ID:RChandrasekar,项目名称:tensorflow,代码行数:16,代码来源:benchmark.py
示例4: main
def main():
global FLAGS
# Parses flags.
parser = argparse.ArgumentParser(
description="Invoke SavedModel to frozen model converter.")
parser.add_argument(
"saved_model_directory",
type=str,
help="Full path to directory containing the SavedModel.")
parser.add_argument(
"output_file_model",
type=str,
help="Full file path to save frozen graph.")
parser.add_argument(
"output_file_flags", type=str, help="Full file path to save ModelFlags.")
parser.add_argument(
"--input_arrays",
type=str,
help="Name of the input arrays, comma-separated.")
parser.add_argument(
"--input_shapes",
type=str,
help="Shapes corresponding to --input_arrays, colon-separated.")
parser.add_argument(
"--output_arrays",
type=str,
help="Name of the output arrays, comma-separated.")
parser.add_argument(
"--tag_set", type=str, help="Name of output arrays, comma-separated.")
parser.add_argument(
"--signature_key",
type=str,
help="Key identifying SignatureDef containing inputs and outputs.")
parser.add_argument(
"--batch_size",
type=int,
help="Batch size for the model. Replaces the first dimension of an "
"input size array if undefined.")
FLAGS, unparsed = parser.parse_known_args()
app.run(main=execute, argv=[sys.argv[0]] + unparsed)
开发者ID:Jackiefan,项目名称:tensorflow,代码行数:42,代码来源:convert_saved_model_to_frozen_graph.py
示例5: benchmarks_main
def benchmarks_main(true_main, argv=None):
"""Run benchmarks as declared in argv.
Args:
true_main: True main function to run if benchmarks are not requested.
argv: the command line arguments (if None, uses sys.argv).
"""
if argv is None:
argv = sys.argv
found_arg = [arg for arg in argv
if arg.startswith("--benchmarks=")
or arg.startswith("-benchmarks=")]
if found_arg:
# Remove --benchmarks arg from sys.argv
argv.remove(found_arg[0])
regex = found_arg[0].split("=")[1]
app.run(lambda _: _run_benchmarks(regex), argv=argv)
else:
true_main()
开发者ID:1000sprites,项目名称:tensorflow,代码行数:20,代码来源:benchmark.py
示例6: main
def main():
global FLAGS
parser = argparse.ArgumentParser(
description="Invoke toco using protos as input.")
parser.add_argument(
"model_proto_file",
type=str,
help="File containing serialized proto that describes the model.")
parser.add_argument(
"toco_proto_file",
type=str,
help="File containing serialized proto describing how TOCO should run.")
parser.add_argument(
"model_input_file", type=str, help="Input model is read from this file.")
parser.add_argument(
"model_output_file",
type=str,
help="Result of applying TOCO conversion is written here.")
FLAGS, unparsed = parser.parse_known_args()
app.run(main=execute, argv=[sys.argv[0]] + unparsed)
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:22,代码来源:toco_from_protos.py
示例7:
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.register('type', 'bool', lambda v: v.lower() == 'true')
parser.add_argument(
'--config_path',
type=str,
default='delf_config_example.pbtxt',
help="""
Path to DelfConfig proto text file with configuration to be used for DELF
extraction.
""")
parser.add_argument(
'--list_images_path',
type=str,
default='list_images.txt',
help="""
Path to list of images whose DELF features will be extracted.
""")
parser.add_argument(
'--output_dir',
type=str,
default='test_features',
help="""
Directory where DELF features will be written to. Each image's features
will be written to a file with same name, and extension replaced by .delf.
""")
cmd_args, unparsed = parser.parse_known_args()
app.run(main=main, argv=[sys.argv[0]] + unparsed)
开发者ID:zhangjiulong,项目名称:models,代码行数:28,代码来源:extract_features.py
示例8: ParseEventFilesFlag
path_to_run = ParseEventFilesFlag(FLAGS.logdir)
multiplexer = event_multiplexer.AutoloadingMultiplexer(
path_to_run=path_to_run, interval_secs=60,
size_guidance=TENSORBOARD_SIZE_GUIDANCE)
multiplexer.AutoUpdate(interval=30)
factory = functools.partial(tensorboard_handler.TensorboardHandler,
multiplexer)
try:
server = ThreadedHTTPServer((FLAGS.host, FLAGS.port), factory)
except socket.error:
logging.error('Tried to connect to port %d, but that address is in use.',
FLAGS.port)
return -2
try:
tag = resource_loader.load_resource('tensorboard/TAG').strip()
logging.info('TensorBoard is tag: %s', tag)
except IOError:
logging.warning('Unable to read TensorBoard tag')
tag = ''
status_bar.SetupStatusBarInsideGoogle('TensorBoard %s' % tag, FLAGS.port)
print('Starting TensorBoard %s on port %d' % (tag, FLAGS.port))
print('(You can navigate to http://localhost:%d)' % FLAGS.port)
server.serve_forever()
if __name__ == '__main__':
app.run()
开发者ID:bgyss,项目名称:tensorflow,代码行数:30,代码来源:tensorboard.py
示例9: main
def main():
app.run(main=run_main, argv=sys.argv[:1])
开发者ID:HughKu,项目名称:tensorflow,代码行数:2,代码来源:tflite_convert.py
示例10: print
:nb_samples], Y_test[:nb_samples], args=eval_par)
t2 = time.time()
print('Test accuracy on adversarial examples %0.4f\n' % acc)
print("Took", t2 - t1, "seconds")
if __name__ == '__main__':
if "CIFAR10_CHALLENGE_DIR" in os.environ:
cifar10_root = os.environ['CIFAR10_CHALLENGE_DIR']
default_ckpt_dir = os.path.join(cifar10_root, 'models/adv_trained')
default_data_dir = os.path.join(cifar10_root, 'cifar10_data')
flags.DEFINE_integer('batch_size', 100, "Batch size")
flags.DEFINE_integer('nb_samples', 1000, "Number of samples to test")
flags.DEFINE_string('attack_type', 'fgsm', ("Attack type: 'fgsm'->'fast "
"gradient sign method', "
"'pgd'->'projected "
"gradient descent', 'cwl2'->"
"'Carlini & Wagner L2'"))
flags.DEFINE_string('checkpoint_dir', default_ckpt_dir,
'Checkpoint directory to load')
flags.DEFINE_string('dataset_dir', default_data_dir, 'Dataset directory')
flags.DEFINE_bool('sweep', False, 'Sweep epsilon or single epsilon?')
app.run(main)
开发者ID:limin24kobe,项目名称:cleverhans,代码行数:30,代码来源:attack_model.py
示例11: main_wrapper
def main_wrapper():
args = argv
if args is None:
args = sys.argv
return app.run(main=g_main, argv=args)
开发者ID:LUTAN,项目名称:tensorflow,代码行数:5,代码来源:googletest.py
示例12: run_main
def run_main():
parser = argparse.ArgumentParser()
parser.register("type", "bool", lambda v: v.lower() == "true")
parser.add_argument(
"--input_graph",
type=str,
default="",
help="TensorFlow \'GraphDef\' file to load.")
parser.add_argument(
"--input_saver",
type=str,
default="",
help="TensorFlow saver file to load.")
parser.add_argument(
"--input_checkpoint",
type=str,
default="",
help="TensorFlow variables file to load.")
parser.add_argument(
"--checkpoint_version",
type=int,
default=2,
help="Tensorflow variable file format")
parser.add_argument(
"--output_graph",
type=str,
default="",
help="Output \'GraphDef\' file name.")
parser.add_argument(
"--input_binary",
nargs="?",
const=True,
type="bool",
default=False,
help="Whether the input files are in binary format.")
parser.add_argument(
"--output_node_names",
type=str,
default="",
help="The name of the output nodes, comma separated.")
parser.add_argument(
"--restore_op_name",
type=str,
default="save/restore_all",
help="""\
The name of the master restore operator. Deprecated, unused by updated \
loading code.
""")
parser.add_argument(
"--filename_tensor_name",
type=str,
default="save/Const:0",
help="""\
The name of the tensor holding the save path. Deprecated, unused by \
updated loading code.
""")
parser.add_argument(
"--clear_devices",
nargs="?",
const=True,
type="bool",
default=True,
help="Whether to remove device specifications.")
parser.add_argument(
"--initializer_nodes",
type=str,
default="",
help="Comma separated list of initializer nodes to run before freezing.")
parser.add_argument(
"--variable_names_whitelist",
type=str,
default="",
help="""\
Comma separated list of variables to convert to constants. If specified, \
only those variables will be converted to constants.\
""")
parser.add_argument(
"--variable_names_blacklist",
type=str,
default="",
help="""\
Comma separated list of variables to skip converting to constants.\
""")
parser.add_argument(
"--input_meta_graph",
type=str,
default="",
help="TensorFlow \'MetaGraphDef\' file to load.")
parser.add_argument(
"--input_saved_model_dir",
type=str,
default="",
help="Path to the dir with TensorFlow \'SavedModel\' file and variables.")
parser.add_argument(
"--saved_model_tags",
type=str,
default="serve",
help="""\
Group of tag(s) of the MetaGraphDef to load, in string format,\
separated by \',\'. For tag-set contains multiple tags, all tags \
#.........这里部分代码省略.........
开发者ID:AnishShah,项目名称:tensorflow,代码行数:101,代码来源:freeze_graph.py
示例13: main_wrapper
def main_wrapper():
return app.run(main=g_main, argv=sys.argv)
开发者ID:kadeng,项目名称:tensorflow,代码行数:2,代码来源:googletest.py
注:本文中的tensorflow.python.platform.app.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论