[TensorFlow] Basic Usage
Install TensorFlow on mac
Install pip
# Mac OS X
$ sudo easy_install pip
$ sudo easy_install --upgrade six
Install tensorflow
# Mac OS X, CPU only, Python 2.7:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl
Basic Usage
The concepts in TensorFlow
Tensor : a typed multi-dimensional array. Only Tensor are passed between operations in the computation graph.
Graph : a description of computation.
op : (short for operation) the node in the graph
Session : the context in which to execute graphs
Devices : such as CPUs or GPUs, on which Session execute graphs
Variable : maintain state
numpy ndarray : the result structure returned by Sesson.run(graph), which is produced by ops in graph and transformed from tensor
Simple example
import tensorflow as tf # Start with default graph.
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
# Now the default graph has three nodes: two constant() ops and one matmul() op. # Launch the default graph in a Session
sess = tf.Session()
result = sess.run(product)
print(result)
sess.close()
The call 'run(product)' causes the execution of three ops in the graph.
Fetches : to fech the outputs of operations, execute the graph with a run() call on the Session object. E.g. sess.run(product) in above sample
Feeds : a mechanism for patching tensors directly into operations in graph. Supply feed data as argument to a run() call. tf.placeholder is used to create "feed" operations commonly
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
output = tf.mul(input1, input2) with tf.Session() as sess:
print(sess.run([output], feed_dict={input1:[7.], input2:[2.]})) # output:
# [array([ 14.], dtype=float32)]
References
Download and Setup, TensorFlow
[TensorFlow] Basic Usage的更多相关文章
- zookeeper kazoo Basic Usage
http://kazoo.readthedocs.org/en/latest/basic_usage.html Basic Usage Connection Handling To begin usi ...
- 【C++/C】指针基本用法简介-A Summary of basic usage of Pointers.
基于谭浩强老师<C++程序设计(第三版)>做简要Summary.(2019-07-24) 一.数组与指针 1. 指针数组 一个数组,其元素均为指针类型数据,该数组称为指针数组.(type_ ...
- python Basic usage
__author__ = 'student' l=[] l=list('yaoxiaohua') print l print l[0:2] l=list('abc') print l*3 l.appe ...
- github basic usage in windows
1. create a new accout, create orginazation, create repo 2. install git in your local pc Note: you c ...
- TensorFlow 中文资源全集,官方网站,安装教程,入门教程,实战项目,学习路径。
Awesome-TensorFlow-Chinese TensorFlow 中文资源全集,学习路径推荐: 官方网站,初步了解. 安装教程,安装之后跑起来. 入门教程,简单的模型学习和运行. 实战项目, ...
- TensorFlow资源整理
什么是TensorFlow? TensorFlow 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操作,图中的线(edges)则表示 ...
- Awesome TensorFlow
Awesome TensorFlow A curated list of awesome TensorFlow experiments, libraries, and projects. Inspi ...
- TensorFlow 中文资源精选,官方网站,安装教程,入门教程,实战项目,学习路径。
Awesome-TensorFlow-Chinese TensorFlow 中文资源全集,学习路径推荐: 官方网站,初步了解. 安装教程,安装之后跑起来. 入门教程,简单的模型学习和运行. 实战项目, ...
- R用户的福音︱TensorFlow:TensorFlow的R接口
------------------------------------------------------------ Matt︱R语言调用深度学习架构系列引文 R语言︱H2o深度学习的一些R语言实 ...
随机推荐
- CodeForces 652D Nested Segments
离散化+树状数组 先对坐标离散化,把每条线段结尾所在点标1, 询问某条线段内有几条线段的时候,只需询问这段区间的和是多少,询问结束之后再把这条线段尾部所在点标为0 #include<cstdio ...
- HTML学习(六)图像
图像标签(<img>)和源属性(Src)在 HTML 中,图像由 <img> 标签定义.<img> 是空标签,意思是说,它只包含属性,并且没有闭合标签.要在页面上显 ...
- spring 自动化构建项目
STS 3.7.0.RELEASE http://spring.io/tools/sts/legacy
- 史上最坑的证书报错解决方法:Code=3000 "未找到应用程序的“aps-environment”的权利字符串"
在ios注册远程通知获取设备令牌token的时候 // 注册远程通知获取设备令牌 toKen [[ UIApplication sharedApplication ] registerForRemot ...
- NLPIR中文分词器的使用
一.普通java项目 (1)添加项目jar包 File -> Project Structure Libarries 添加jar包jna-4.0.0.jar (2)将Data文件夹复制到 ...
- UWP_小说在线阅读器:功能要求与技术要求
学了WP开发也有一年了,也没做过什么软件的.17年进发UWP,锻炼自己一下.做一个开源的小说阅读器吧. 既然开发一个软件.所以要设计一下吧. 功能要求: 可能要用到的技术,这个吗,这就是遇到问题在解决 ...
- FAB、TextInputLayout及Snackbar笔记
FloatingActionButton 由于FloatingActionButton是重写ImageView的,所有FloatingActionButton拥有ImageView的一切属性. 控制F ...
- 1)Java学习笔记:接口和抽象类的异同
Java接口和抽象类很像,他们有哪些相同点和异同点呢,下面我们做一个小结 相同 ① 都不能被实例化,都位于继承树的顶端,用于被实现或者继承 ② 都可以包含抽象方法,实现接口或者继承抽象类的普通子类都必 ...
- java 解析excel
2014年2月25日 14:24:48 解析excel方法 //首先是jar包下载,请自行百度 //代码 package cn.wuwenfu.excel; import java.io.File; ...
- linux 同步机制之complete【转】
转自: http://blog.csdn.net/wealoong/article/details/8490654 在Linux内核中,completion是一种简单的同步机制,标志"thi ...