tensorflow2:tf.app.run()
在很多TensorFlow公布的Demo中,都有这样的代码存在,如下,这是干什么的呢?
我们来看一下源代码:
# tensorflow/tensorflow/python/platform/default/_app.py # Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================== """Generic entry point script."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function import sys from tensorflow.python.platform import flags def run(main=None):
f = flags.FLAGS
f._parse_flags()
main = main or sys.modules['__main__'].main
sys.exit(main(sys.argv))
处理flag解析,然后执行main函数,那么flag解析是什么意思呢?诸如这样的:
tf.app.flags.DEFINE_boolean("self_test", False, "True if running a self test.")
tf.app.flags.DEFINE_boolean('use_fp16', False,
"Use half floats instead of full floats if True.")
FLAGS = tf.app.flags.FLAGS
tensorflow2:tf.app.run()的更多相关文章
- tf.app.run() 运行结束时,报错:SystemExit exception: no description
环境:Python3.6.6 + tensorflow-gpu 源码如下: import tensorflow as tf def main(): print("hello tf.app.r ...
- tf.app.run()
在很多TensorFlow公布的Demo中,都有这样的代码存在,如下,这是干什么的呢? if __name__ == "__main__": tf.app.run() 我们来看一下 ...
- tf.app.run() got unexpected keyword argument 'argv'
运行的代码是mnist_with_summaries.py.出现的问题是 tf.app.run() got unexpected keyword argument 'argv' 昨天一直以为是我自己不 ...
- tensorflow中的tf.app.run()的使用
指明函数的入口,即从哪里执行函数. 如果你的代码中的入口函数不叫main(),而是一个其他名字的函数,如test(),则你应该这样写入口tf.app.run(test()) 如果你的代码中的入口函数叫 ...
- tensorflow命令行参数:tf.app.flags.DEFINE_string、tf.app.flags.DEFINE_integer、tf.app.flags.DEFINE_boolean
tf 中定义了 tf.app.flags.FLAGS ,用于接受从终端传入的命令行参数,相当于对Python中的命令行参数模块optpars(参考:python中处理命令行参数的模块optpars)做 ...
- tf.app.run()的作用
tf.app.run() 如果你的代码中的入口函数不叫main(),而是一个其他名字的函数,如test(),则你应该这样写入口tf.app.run(test) 如果你的代码中的入口函数叫main(), ...
- TensorFlow学习笔记之--[tf.app.flags使用方法]
很多时候在运行python代码的时候我们需要从外部定义参数,从而避免每次都需要改动代码.所以一般我们都会使用 argparse 这个库.其实TensorFlow也提供了这个功能,那就是 tf.app. ...
- TensorFlow tf.app&tf.app.flags用法介绍
TensorFlow tf.app&tf.app.flags用法介绍 TensorFlow tf.app argparse tf.app.flags 下面介绍 tf.app.flags.FL ...
- 【转载】 TensorFlow tf.app&tf.app.flags用法介绍
作 者:marsggbo 出 处:https://www.cnblogs.com/marsggbo版权声明:署名 - 非商业性使用 - 禁止演绎,协议普通文本 | 协议法律文本. ---------- ...
随机推荐
- 【TP5.0】model的操作方法
tp5 中 model 的新增方法 //默认主键为自动识别,如果需要指定,可以设置属性: namespace app\index\model; use think\Model; class User ...
- 阿里员工都是这样排查Java问题的,附工具单(转)
平时的工作中经常碰到很多疑难问题的处理,在解决问题的同时,有一些工具起到了相当大的作用,在此书写下来,一是作为笔记,可以让自己后续忘记了可快速翻阅,二是分享,希望看到此文的同学们可以拿出自己日常觉得帮 ...
- cas配置不通过登陆校验的页面
项目中的单点登录是通过CAS配置的,如果是未登录状态,那么请求在通过CAS过滤器校验时会转向登陆页面,无法通过访问类似http://localhost:8080/portal/business-plu ...
- ios实例开发精品文章推荐(8.14)
1.iOS源码:俄罗斯方块实现简单的俄罗斯方块游戏.<ignore_js_op> 下载地址:http://www.apkbus.com/android-124628-1-1.html 2. ...
- Cordova笔记(一)
跨平台的PhoneGap被Adobe收购,改名为Cordova,现在是Apache下的一款开源软件.网上能找到的关于PhoneGap的教程有些方法已不适用,在学习使用最新版的Cordova时有些问题需 ...
- Windows系统使用vbs脚本或bat脚本强制杀死指定所有进程 vbs实现循环持续写入内容到vbs打开开的记事本 使用vbs、bat添加windows计划任务 使用cmd schtasks命令添加windows计划任务
以下脚本windows7下成功运行过,脚本也可以windows计划任务程序一起组合使用 新建一个记事本文档粘贴下面代码后将新建的记事本文档重命名下面对应的脚本名就能使用了: 添加windows计划任务 ...
- WCF异步调用
添加引用服务--高级--选中 生产异步操作 服务端接口操作 [OperationContract]int Add(int a, int b); 客户端: 引用服务:在引用服务时,左下角点击“高级”按钮 ...
- Linux下面安装RabbitMQ Cluster
安装rabbitmq cluster: 设置 Erlang Cookie安装完RabbitMQ之后,在第一台机器上面启动RabbitMQ,然后在停止.复制node1上的/var/lib/rabbitm ...
- 代码管理(二)sourcetree 安装与使用
一 .SourceTree简介 SourceTree 是 Windows 和Mac OS X 下免费的 Git 和 Hg 客户端,拥有可视化界面,容易上手操作.同时它也是Mercurial和Subve ...
- FFmpeg 滤镜及其效果
原文地址:https://blog.csdn.net/dangxw_/article/details/49001413 代码中使用滤镜参见上一篇博客:http://blog.csdn.net/dang ...