首页 > 其他 > 详细

Better performance with tf.function(TensorFlow/学习/TensorFlow Core/指南)

时间:2020-07-10 17:09:42      阅读:83      评论:0      收藏:0      [点我收藏+]

本文原始页面链接:https://tensorflow.google.cn/guide/function

在TensorFlow 2.x系列的版本,eager execution功能是默认打开的,用户接口更直观和灵活,但是代价体现在性能和部署的方面。
想要得到性能和便携性都很好的模型,可以使用tf.function从你的程序中生成图(graph)。但是关于tf.function也有一些问题/陷阱需要注意,本文帮助你理解tf.function到底在做些什么,以方便你掌握它。

主要结论和建议包括:

  • 使用Eager execution模式debug,使用tf.function装饰函数 / Debug in Eager mode, then decorate with @tf.function.
  • 不要依赖python副作用,如对象转变或者是列表append / Don‘t rely on Python side effects like object mutation or list appends.
  • tf.function与TensorFlow op搭配工作的最好,numpy和python调用被转换成常量 / tf.function works best with TensorFlow ops; NumPy and Python calls are converted to constants.

Better performance with tf.function(TensorFlow/学习/TensorFlow Core/指南)

原文:https://www.cnblogs.com/banluxinshou/p/13279937.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!