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. CentOS 6.3下源码编译安装LAMP

    一.简介 什么是LAMP    LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而言都是在它所代 ...

  2. Yii2-redis安装配置

    编辑composer.json文件 vim composer.json 加入"yiisoft/yii2-redis": "~2.0.0" 执行更新 compos ...

  3. MySQL权限及登陆、退出方法

    用户权限列表 SELECT 查询权限 INSERT 插入权限 UPDATE 更新权限 DELETE 删除权限(用于删除数据) CREATE 创建权限 DROP 删除权限(用户删除文件) RELOAD ...

  4. P3256 [JLOI2013]赛车

    传送门 如果把速度看成斜率,起始位置看成截距,这就是一个水平可见直线了-- 不过这题里我实现方法借鉴了CQzhangyu大佬的,先按速度排序,然后维护一个单调栈,如果当前的人速度比栈顶大距离又比它远直 ...

  5. 使用printf和String.format格式化输出

    格式化输出 在哪些情况下使用格式化输出: 异常打印到日志中使用格式化输出有利于排查错误原因: printf格式化 示例: public class PrintfTest { public static ...

  6. HDU 1879(最小生成树)

    #include "iostream" #include "algorithm" #include "cstdio" using names ...

  7. 全面学习ORACLE Scheduler特性(1)创建jobs

    所谓出于job而胜于job,说的就是Oracle 10g后的新特性Scheduler啦.在10g环境中,ORACLE建议使用Scheduler替换普通的job,来管理任务的执行.其实,将Schedul ...

  8. Java 8 (10) CompletableFuture:组合式异步编程

    随着多核处理器的出现,提升应用程序的处理速度最有效的方式就是可以编写出发挥多核能力的软件,我们已经可以通过切分大型的任务,让每个子任务并行运行,使用线程的方式,分支/合并框架(java 7) 和并行流 ...

  9. Quartz.Net学习笔记(2)-简介

    一.Quartz.Net是什么 1.来源 Quartz.Net是一个开源的作业调度框架: 2.下载地址 官网地址:http://www.quartz-scheduler.net/documentati ...

  10. 关于vue项目 路由中 使用的坑

    关于vue路由重定向的时候 记得一定要先声明先声明