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 ...
随机推荐
- 解决 android.support.v7.widget.GridLayout 使用 xmlns:app 出现 error 的问题
GridLayout 是在 Android API Level 14 加进来的 它可用来取代 TableLayout 也提供了自由度较大且实用的排版功能 为了兼容 4.0 以下的较低版本 Androi ...
- 在Angular中定义共享的Providers
转自:https://segmentfault.com/a/1190000010700308 有时,你需要在 Angular 应用中创建一个共享模块,该模块定义了功能模块和lazy-loaded模块可 ...
- 部分函数依赖 && 完全函数依赖
部分函数依赖:若x->y 并且,存在X的真子集x1,使得x1->y,则 y部分依赖于x. 完全函数依赖:若x->y并且,对于x的任何一个真子集x1,都不存在x1->y,则称y完 ...
- Java Mongodbjar包下载网址
http://mongodb.github.io/mongo-java-driver/
- poj2159
题解: 记录一下每个串每个字母出现的次数 排序 然后看看是否相等 代码: #include<cstdio> #include<cstring> #include<cstr ...
- Fragment在Activity中跳转,实现类似新闻标题跳转新闻内容功能
1.准备的工作,新闻数据类,新闻数据适配器,适配器的布局: News.java package com.example.zps.fourfragmentbestpractice; /** * Crea ...
- elasticsearch 自定义similarity 插件开发
转自:http://www.chepoo.com/elasticsearch-similarity-custom-plug-in-development.html 在搜索开发中,我们要修改打分机制,就 ...
- 今天廷鹏师弟来的java建议
如下一段获取数据代码的问题: public Serializable getById(Serializable id) throws BaseBusinessException { if (id = ...
- c#.net利用RNGCryptoServiceProvider产生任意范围强随机数的办法
//这样产生0 ~ 100的强随机数(含100)int max = 100;int rnd = int.MinValue;decimal _base = (decimal)long.MaxValue; ...
- 初始化一个static的Map变量
第一种方法:static块初始化 public class Demo{ private static final Map<String, String> myMap; static { m ...