调用该API可以不通过 tensorflow.Session.run()调用 定义的张量constant tensor,可以直接print

# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import numpy as np
import tensorflow as tf
import tensorflow.contrib.eager as tfe # 设置 eager API
tfe.enable_eager_execution() a = tf.constant(2)
b = tf.constant(3)
print('a = %i' % a)
print('b = %i' % b)
# run op no tf.Session.run()
print("can run op without tf.Session.run") c = a + b
c1 = a * b
print("no Session... c=%i" % c)
print("no Session... c1=%i" % c1) # eagerAPI完全兼容numpy
# 定义张量 define constant tensors
a = tf.constant([[2., 1.],[1., 0]], dtype=tf.float32) # tensor
b = tf.constant([[3., 0.],[5., 1.]], dtype=tf.float32)
c2 = tf.matmul(a, b) # 矩阵相乘matmul print("tensor:\n a=%s" % a)
print("tensor:\n b=%s" % b)
print("tensor multply :\n c2=%s" % c2) print(a.shape[0]) # 多少组维度信息
print(a.shape[1]) # 维度 # tensor对象能够迭代? range ?????
for i in range(a.shape[0]):
for u in range(a.shape[1]):
print(a[i][u])

tensorflow-eagerAPI的更多相关文章

  1. Tensorflow 官方版教程中文版

    2015年11月9日,Google发布人工智能系统TensorFlow并宣布开源,同日,极客学院组织在线TensorFlow中文文档翻译.一个月后,30章文档全部翻译校对完成,上线并提供电子书下载,该 ...

  2. tensorflow学习笔记二:入门基础

    TensorFlow用张量这种数据结构来表示所有的数据.用一阶张量来表示向量,如:v = [1.2, 2.3, 3.5] ,如二阶张量表示矩阵,如:m = [[1, 2, 3], [4, 5, 6], ...

  3. 用Tensorflow让神经网络自动创造音乐

    #————————————————————————本文禁止转载,禁止用于各类讲座及ppt中,违者必究————————————————————————# 前几天看到一个有意思的分享,大意是讲如何用Ten ...

  4. tensorflow 一些好的blog链接和tensorflow gpu版本安装

    pading :SAME,VALID 区别  http://blog.csdn.net/mao_xiao_feng/article/details/53444333 tensorflow实现的各种算法 ...

  5. tensorflow中的基本概念

    本文是在阅读官方文档后的一些个人理解. 官方文档地址:https://www.tensorflow.org/versions/r0.12/get_started/basic_usage.html#ba ...

  6. kubernetes&tensorflow

    谷歌内部--Borg Google Brain跑在数十万台机器上 谷歌电商商品分类深度学习模型跑在1000+台机器上 谷歌外部--Kubernetes(https://github.com/kuber ...

  7. tensorflow学习

    tensorflow安装时遇到gcc: error trying to exec 'as': execvp: No such file or directory. 截止到2016年11月13号,源码编 ...

  8. 【转】TensorFlow练习20: 使用深度学习破解字符验证码

    验证码是根据随机字符生成一幅图片,然后在图片中加入干扰象素,用户必须手动填入,防止有人利用机器人自动批量注册.灌水.发垃圾广告等等 . 验证码的作用是验证用户是真人还是机器人:设计理念是对人友好,对机 ...

  9. 【转】机器学习教程 十四-利用tensorflow做手写数字识别

    模式识别领域应用机器学习的场景非常多,手写识别就是其中一种,最简单的数字识别是一个多类分类问题,我们借这个多类分类问题来介绍一下google最新开源的tensorflow框架,后面深度学习的内容都会基 ...

  10. 【转】Ubuntu 16.04安装配置TensorFlow GPU版本

    之前摸爬滚打总是各种坑,今天参考这篇文章终于解决了,甚是鸡冻\(≧▽≦)/,电脑不知道怎么的,安装不了16.04,就安装15.10再升级到16.04 requirements: Ubuntu 16.0 ...

随机推荐

  1. 一个产生临时图片Url的地方

  2. ActiveStorage. 英文书Learnrails5.2的案例,看如何放到云上。

    ActiveStorage. 英文书Learnrails5.2的案例 本例子目标:增加一个avatar image给每个用户. 准备: 需要安装Imagemagick software.它可以crea ...

  3. TCP握手及状态图

    为什么需要“三次握手”? 为了解决“网络中存在延迟的重复分组”的问题,即为了防止已失效的连接请求报文段突然又传送到了服务端,因而产生错误. 例:“已失效的连接请求报文段”的产生在这样一种情况下:cli ...

  4. LTE空口协议——是空口3GPP协议 不是网络IP协议

    [LTE基础知识]LTE空口协议分析 from:https://www.mscbsc.com/viewnews-102038.html控制面协议 控制面协议结构如下图所示. PDCP在网络侧终止于eN ...

  5. JavaScript学习总结(二十二)——JavaScript屏蔽Backspace键

    今天在IE浏览器下发现,当把使用readonly="readonly"属性将文本框设置成只读<input type="text" readonly=&qu ...

  6. vue.js利用vue.router创建前端路由

    node.js方式: 利用node.js安装vue-router模块 cnpm install vue-router 安装完成后我们引入这个模板! 下载vue-router利用script引入方式: ...

  7. SGU 132. Another Chocolate Maniac 状压dp 难度:1

    132. Another Chocolate Maniac time limit per test: 0.25 sec. memory limit per test: 4096 KB Bob real ...

  8. New Concept English Two 26 70

    $课文68  纠缠不休 712. I crossed the street to avoid meeting him, but he saw me and came running towards m ...

  9. New Concept English Two 15 37

    listening speaking reading writing and translating $课文35  捉贼! 355. Roy Trenton used to drive a taxi. ...

  10. 关于yo3 所遇到的问题

    关于去哪儿开发的yo3 库,实在不敢恭维 ,没有最坑,只有更坑. 官方文档写的实在是 ,有element,iview,ant-design等等一半也可以 ,个人观点. 在使用Scroller中, 自动 ...