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的更多相关文章

  1. 独家 | TensorFlow 2.0将把Eager Execution变为默认执行模式,你该转向动态计算图了

    机器之心报道 作者:邱陆陆 8 月中旬,谷歌大脑成员 Martin Wicke 在一封公开邮件中宣布,新版本开源框架——TensorFlow 2.0 预览版将在年底之前正式发布.今日,在上海谷歌开发者 ...

  2. 关于TensorFlow你需要了解的9件事

    关于TensorFlow你需要了解的9件事 https://mp.weixin.qq.com/s/cEQAdLnueMEj0OQZtYvcuw 摘要:本文对近期在旧金山举办的谷歌 Cloud Next ...

  3. [源码解析] TensorFlow 分布式之 ParameterServerStrategy V2

    [源码解析] TensorFlow 分布式之 ParameterServerStrategy V2 目录 [源码解析] TensorFlow 分布式之 ParameterServerStrategy ...

  4. 2018百度之星开发者大赛-paddlepaddle学习

    前言 本次比赛赛题是进行人流密度的估计,因为之前看过很多人体姿态估计和目标检测的论文,隐约感觉到可以用到这次比赛上来,所以趁着现在时间比较多,赶紧报名参加了一下比赛,比赛规定用paddlepaddle ...

  5. [源码解析] 深度学习分布式训练框架 horovod (7) --- DistributedOptimizer

    [源码解析] 深度学习分布式训练框架 horovod (7) --- DistributedOptimizer 目录 [源码解析] 深度学习分布式训练框架 horovod (7) --- Distri ...

  6. TensorFlow tutorial

    代码示例来自https://github.com/aymericdamien/TensorFlow-Examples tensorflow先定义运算图,在run的时候才会进行真正的运算. run之前需 ...

  7. Tensorflow word2vec+manage experiments

    Lecture note 5: word2vec + manage experiments Word2vec Most of you are probably already familiar wit ...

  8. Linear and Logistic Regression in TensorFlow

    Linear and Logistic Regression in TensorFlow Graphs and sessions TF Ops: constants, variables, funct ...

  9. 浅析 TensorFlow Runtime 技术

    关于 TF Runtime 的疑问? 什么是TFRT ? TensorFlow Runtime,简称 TFRT,它提供了统一的.可扩展的基础架构层,可以极致地发挥CPU多线程性能,支持全异步编程(无锁 ...

随机推荐

  1. sshfs把远程主机的文件系统映射到本地的目录中(转载)

    转自:http://www.fwolf.com/blog/post/329 windows之外的世界比想像中要大得多呢,几乎天天都在用ssh,却到今天才知道有sshfs这个好东西,前几天还在为Zend ...

  2. Win10出现键盘未失灵,按下的键都是快捷键的问题

    某一天,WIN10开机.然后键盘莫名其妙的都无法正常使用,没有卡Window键,键盘也没有失灵,按下的键都成为了快捷键:终于在   https://zhidao.baidu.com/question/ ...

  3. bzoj 1045: [HAOI2008] 糖果传递【瞎搞】

    感觉我的智商可能不够写题解,就直接截了hzwer的blog 地址http://hzwer.com/2656.html #include<iostream> #include<cstd ...

  4. ASP.NET SQL 总结(2)

    Sql常见面试题(总结) 1.用一条SQL语句 查询出每门课都大于80分的学生姓名 name   kecheng   fenshu 张三     语文       81 张三     数学       ...

  5. 2017杭电多校第六场1008 Kirinriki

    传送门 Kirinriki Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  6. 383 Ransom Note 赎金信

    给定一个赎金信 (ransom) 字符串和一个杂志(magazine)字符串,判断第一个字符串ransom能不能由第二个字符串magazines里面的字符构成.如果可以构成,返回 true :否则返回 ...

  7. hihocoder1365 图片排版

    思路: 模拟,枚举,dp. 参考了https://github.com/buptlxb/hihoCoder/blob/master/solutions/1365/picture_arrange.cpp ...

  8. leetcode486 Predict the Winner

    思路: 博弈. 实现: class Solution { public: bool PredictTheWinner(vector<int>& nums) { ][]; int n ...

  9. ubuntu系统中查看本机cpu和内存信息的命令和用法

    https://zhidao.baidu.com/question/192966322.html 写出ubuntu linux系统中查看本机cpu和内存信息的命令和用法,以及如何解读这些命令 ubun ...

  10. 华硕(ASUS)X554LP笔记本在64位win7下无线网络连接问题

    还是那台华硕(ASUS)X554LP笔记本,无线网卡为 Qualcomm Atheros AR956x,某天换了个环境,WIFI(此处简称为WIFI网A)就连不上网了.手机.其它笔记本用无线连接都没问 ...