首页 > 其他 > 详细

Tensorflow Eager execution and interface

时间:2018-12-22 23:58:28      阅读:336      评论:0      收藏:0      [点我收藏+]

Lecture note 4: Eager execution and interface

Eager execution

Eager execution is (1) a NumPy-like library for numerical computation with support for GPU acceleration and automatic differentiation, and (2) a flexible platform for machine learning research and experimentation. It‘s available as tf.contrib.eager, starting with version 1.50 of TensorFlow.

 

  • Motivation:
    • TensorFlow today: Construct a graph and execute it.
      • This is declarative programming. Its benefits include performance and easy translation to other platforms; drawbacks include that declarative programming is non-Pythonic and difficult to debug.
    • What if you could execute operations directly?
      • Eager execution offers just that: it is an imperative front-end to TensorFlow.
  • Key advantages: Eager execution …
    • is compatible with Python debugging tools
      • pdb.set_trace() to your heart‘s content!
    • provides immediate error reporting
    • permits use of Python data structures
      • e.g., for structured input
    • enables you to use and differentiate through Python control flow
  • Enabling eager execution requires two lines of code

     

    import tensorflow as tf

    import tensorflow.contrib.eager as tfe

    tfe.enable_eager_execution() # Call this at program start-up

 

    and lets you write code that you can easily execute in a REPL, like this

 

x = [[2.]] # No need for placeholders!

m = tf.matmul(x, x)

 

print(m) # No sessions!

# tf.Tensor([[4.]], shape=(1, 1), dtype=float32)

 

For more details, check out lecture slides 04.

Tensorflow Eager execution and interface

原文:https://www.cnblogs.com/kexinxin/p/10162829.html

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