tensorflow-eagerAPI
调用该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的更多相关文章
- Tensorflow 官方版教程中文版
2015年11月9日,Google发布人工智能系统TensorFlow并宣布开源,同日,极客学院组织在线TensorFlow中文文档翻译.一个月后,30章文档全部翻译校对完成,上线并提供电子书下载,该 ...
- tensorflow学习笔记二:入门基础
TensorFlow用张量这种数据结构来表示所有的数据.用一阶张量来表示向量,如:v = [1.2, 2.3, 3.5] ,如二阶张量表示矩阵,如:m = [[1, 2, 3], [4, 5, 6], ...
- 用Tensorflow让神经网络自动创造音乐
#————————————————————————本文禁止转载,禁止用于各类讲座及ppt中,违者必究————————————————————————# 前几天看到一个有意思的分享,大意是讲如何用Ten ...
- tensorflow 一些好的blog链接和tensorflow gpu版本安装
pading :SAME,VALID 区别 http://blog.csdn.net/mao_xiao_feng/article/details/53444333 tensorflow实现的各种算法 ...
- tensorflow中的基本概念
本文是在阅读官方文档后的一些个人理解. 官方文档地址:https://www.tensorflow.org/versions/r0.12/get_started/basic_usage.html#ba ...
- kubernetes&tensorflow
谷歌内部--Borg Google Brain跑在数十万台机器上 谷歌电商商品分类深度学习模型跑在1000+台机器上 谷歌外部--Kubernetes(https://github.com/kuber ...
- tensorflow学习
tensorflow安装时遇到gcc: error trying to exec 'as': execvp: No such file or directory. 截止到2016年11月13号,源码编 ...
- 【转】TensorFlow练习20: 使用深度学习破解字符验证码
验证码是根据随机字符生成一幅图片,然后在图片中加入干扰象素,用户必须手动填入,防止有人利用机器人自动批量注册.灌水.发垃圾广告等等 . 验证码的作用是验证用户是真人还是机器人:设计理念是对人友好,对机 ...
- 【转】机器学习教程 十四-利用tensorflow做手写数字识别
模式识别领域应用机器学习的场景非常多,手写识别就是其中一种,最简单的数字识别是一个多类分类问题,我们借这个多类分类问题来介绍一下google最新开源的tensorflow框架,后面深度学习的内容都会基 ...
- 【转】Ubuntu 16.04安装配置TensorFlow GPU版本
之前摸爬滚打总是各种坑,今天参考这篇文章终于解决了,甚是鸡冻\(≧▽≦)/,电脑不知道怎么的,安装不了16.04,就安装15.10再升级到16.04 requirements: Ubuntu 16.0 ...
随机推荐
- Angular单元测试
https://angular.github.io/protractor/#/http://jasmine.github.io/2.4/introduction.html 测试程序有两种主要方法:端对 ...
- 优化--前端(全占课,未完成作业:);CDN; Http/2的设置(未完成)
前端效能: 关键渲染路径:Google 文档 JavaScript 加载最佳化 让html和javascript同时渲染: 设置<script>的async或者defer属性(boolea ...
- HTML5-canvas实例:2D折线数据图与2D扇形图
基础知识: <canvas id="demo" width="400" height="400"></canvas> ...
- LTE空口协议——是空口3GPP协议 不是网络IP协议
[LTE基础知识]LTE空口协议分析 from:https://www.mscbsc.com/viewnews-102038.html控制面协议 控制面协议结构如下图所示. PDCP在网络侧终止于eN ...
- BZOJ2958 序列染色
果然清华集训的题目...显然的DP题但是不会做... 我们令f[i][j][w]表示状态方程 w表示到了字符串的第w个 i = 0, 1, 2分别表示k个B和k个W都没填上.k个B填上了k个W没填上. ...
- BZOJ3427 Poi2013 Bytecomputer
可以YY一下嘛= = 最后一定是-1, -1, ..., -1, 0, 0, ... 0, 1, 1, ..., 1的一个数列 于是f[i][j]表示到了第i个数,新数列的第j项为-1 or 0 or ...
- sgu 137. Funny Strings 线性同余,数论,构造 难度:3
137. Funny Strings time limit per test: 0.25 sec. memory limit per test: 4096 KB Let's consider a st ...
- linux系统之间共享文件(CentOS6)
Server IP: 192.168.2.128 nfs, rpcbind(portmap) installed Client IP: 192.168.2.254 nfs, rpcbind(portm ...
- strtol 笔记
今天看了一下网上关于这个函数的解释,根据文章大意记录一下 strtol 是将字符串转换为long int的一个函数 strtol(const char* nptr, char **endptr, in ...
- 在JavaScript中进行文件处理,第四部分:对象URLs
译注:原文是<JavaScript高级程序设计>的作者Nicholas Zakas写的,本翻译纯属为自己学习而做,仅供参考.原文链接:这里 学习到这里,你已经了解在传统方式中如何使用文件, ...