[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语言实 ...
随机推荐
- Ubuntu 开启SSH 以及LAMP环境安装
1. 更新 apt-get sudo apt-get update 2.安装 openssh sudo apt-get install openssh-server 3.设置root账号密码 sudo ...
- mysql建表---级联删除
CREATE TABLE `roottb` ( `id` INT(11) UNSIGNED AUTO_INCREMENT NOT NULL, `data` VARCHAR(100) NOT NUL ...
- SDWEBImage和collectionView的组合,以及collectionView的随意间距设置
#import "ViewController.h" #import <ImageIO/ImageIO.h> #import "UIImageView+Web ...
- quailty's Contest #1 A1 道路修建 Small
暴力.每次合并两个点之后,把新产生的连通关系都记录下来. #include<cstdio> #include<algorithm> #include<vector> ...
- nginx 生成 缩略图 and 生成缩略图到硬盘
nginx 编译的时候增加 ./configure --with-http_image_filter_module 配置如下 server { listen 80; server_name ...
- Instruments使用实战
http://www.cocoachina.com/ios/20150225/11163.html 最近采用Instruments 来分析整个应用程序的性能.发现很多有意思的点,以及性能优化和一些分析 ...
- Memcached源码分析之线程模型
作者:Calix 一)模型分析 memcached到底是如何处理我们的网络连接的? memcached通过epoll(使用libevent,下面具体再讲)实现异步的服务器,但仍然使用多线程,主要有两种 ...
- php连接mysql数据库(新浪云SAE)
新浪云提供了免费的创建服务器端应用的服务.网址为:https://www.sinacloud.com/ 在上面创建好应用,然后在本地使用记事本编写应用的代码如下: <?php echo &quo ...
- PHP7新特性
重写ZenVM,性能比PHP5.6提升300% 新特性: 1.变量类型(为PHP7.1的JIT特性做准备)function test(int $a, string $b, array $c) : in ...
- JQuery checkbox全选多次点击后无效解决方法
1. jquery设置checkbox时: <input type="checkbox" id="ckAll"/> $(function(){ va ...