import tensorflow as tf #参数说明 (变量名,值,说明) tf.app.flags.DEFINE_string( 'master', 'variable', 'The address of the TensorFlow master to use.') tf.app.flags.DEFINE_integer( 'worker_replicas', 1, 'Number of worker replicas.') tf.app.flags.DEFINE_float( 'weight_decay', 0.00004, 'The weight decay on the model weights.') tf.app.flags.DEFINE_boolean( 'clone_on_cpu', False,'Use CPUs to deploy clones.') FLAGS = tf.app.flags.FLAGS print(FLAGS.master) print(FLAGS.worker_replicas) print(FLAGS.weight_decay) print(FLAGS.clone_on_cpu) ''' 输出结果: variable 1 4e-05 False ''' ''' 访问方式1: 需要改变的参数值的需要用--变量名=value python3 flags.py --master=123 --worker_replicas=3 访问方式2: 直接运行,进行操作 '''
TensorFlow中的tf.app.flags使用
最新推荐文章于 2022-09-08 15:04:19 发布
本文介绍了使用TensorFlow进行参数配置的方法,包括定义不同类型的参数及其含义,并演示了两种访问这些参数的方式。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.15
TensorFlow
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型
7505





