Tensorflow tf.app.run 的工作方式

To run a tensorflow app, you define the input, lost fn, model and EvaluationMonitor in a main function in your module like this.

执行 TensorFlow 的应用,需要定义输入、输入、网络模型和评估监控在主函数中,主函数要包含上述信息。

Like this,举例如下:

import tensorflow as tf
def main(unused_argv):
  hparams = ...
  model_fn = ...
  estimator = ...
  input_fn_train = ...
  input_fn_eval = ...
  eval_metrics = ...
  eval_monitor = ...
  # Start to train
  estimator.fit

if __name__ == "__main__":
  tf.app.run()

Note, the last line, you need to fire tf.app.run. All the job are done in main. How does the main function is invoked?

注意,在上面最后一行,要调用 tf.app.run,那么这行的作用是什么?

tf.app.run lays out the thing

It’s just a very quick wrapper that handles flag parsing and then dispatches to your own main.

这个函数用来处理输入 flags,分发命令,启动执行任务。

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/platform/app.py

Explanation code snippets

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值