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. P3154 [CQOI2009]循环赛

    传送门 双倍经验题->这里 //minamoto #include<bits/stdc++.h> #define ll unsigned long long #define R re ...

  2. (前缀和 内存分配)51NOD 1081 子段求和

    给出一个长度为N的数组,进行Q次查询,查询从第i个元素开始长度为l的子段所有元素之和.   例如,1 3 7 9 -1,查询第2个元素开始长度为3的子段和,1 {3 7 9} -1.3 + 7 + 9 ...

  3. 源码阅读之LinkedList(JDK8)

    inkedList概述 LinkedList是List和Deque接口的双向链表的实现.实现了所有可选列表操作,并允许包括null值. LinkedList既然是通过双向链表去实现的,那么它可以被当作 ...

  4. hdu2031

    http://acm.hdu.edu.cn/showproblem.php?pid=2031 #include<stdio.h> #include<math.h> #inclu ...

  5. Linux环境下修改MySQL数据库对表名大小写不敏感

    Linux系统中MySQL对数据库名称和表名是大小写敏感的,这就导致了一些麻烦,虽然已经建立了表和数据,但因为大小写导致无法找到表. MySQL数据库对表名大小写不敏感的设置方法如下: 1.查看MyS ...

  6. Unity笔记(3)自学第二天

    学习记录: 界面使用: 脚本使用: 脚本注意点:

  7. ImmutableJS

    引用大神的一句话:(具体是谁自己问度娘) Shared mutable state is the root of all evil(共享的可变状态是万恶之源) -- Pete Hunt   JavaS ...

  8. PHP开发心得一

    1,php获得服务器时间 $time= date('Y-m-d H:i'); echo $time; 一般写法如上,但发现打印出来的时间小时数总数不对,和机器的时间差几个小时.查资料发现,要设定时区. ...

  9. 继续C#开发or转做产品

    本人今年大四,C#开发,在一家公司实习了一年后,面临一个选择,是继续C#开发还是转做产品?我C#开发能力目前还一般,但很有兴趣.也喜欢设计与创意,做过产品专员.求大婶们指导!

  10. Magento 多站点多域名安装教程(可以设置手机模版哟,亲 \(^o^)/)

    这篇文章是安装magento子域名的教程,请先进行安装之前,确认以下几点: 1.请先确认子域名是否已经指向你的服务器 2.可以编辑.htaccess文件 3. 熟悉Cpanel操作 我们的目标是建立一 ...