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

Basic Usage, TensorFlow

[TensorFlow] Basic Usage的更多相关文章

  1. zookeeper kazoo Basic Usage

    http://kazoo.readthedocs.org/en/latest/basic_usage.html Basic Usage Connection Handling To begin usi ...

  2. 【C++/C】指针基本用法简介-A Summary of basic usage of Pointers.

    基于谭浩强老师<C++程序设计(第三版)>做简要Summary.(2019-07-24) 一.数组与指针 1. 指针数组 一个数组,其元素均为指针类型数据,该数组称为指针数组.(type_ ...

  3. python Basic usage

    __author__ = 'student' l=[] l=list('yaoxiaohua') print l print l[0:2] l=list('abc') print l*3 l.appe ...

  4. github basic usage in windows

    1. create a new accout, create orginazation, create repo 2. install git in your local pc Note: you c ...

  5. TensorFlow 中文资源全集,官方网站,安装教程,入门教程,实战项目,学习路径。

    Awesome-TensorFlow-Chinese TensorFlow 中文资源全集,学习路径推荐: 官方网站,初步了解. 安装教程,安装之后跑起来. 入门教程,简单的模型学习和运行. 实战项目, ...

  6. TensorFlow资源整理

    什么是TensorFlow? TensorFlow 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操作,图中的线(edges)则表示 ...

  7. Awesome TensorFlow

    Awesome TensorFlow  A curated list of awesome TensorFlow experiments, libraries, and projects. Inspi ...

  8. TensorFlow 中文资源精选,官方网站,安装教程,入门教程,实战项目,学习路径。

    Awesome-TensorFlow-Chinese TensorFlow 中文资源全集,学习路径推荐: 官方网站,初步了解. 安装教程,安装之后跑起来. 入门教程,简单的模型学习和运行. 实战项目, ...

  9. R用户的福音︱TensorFlow:TensorFlow的R接口

    ------------------------------------------------------------ Matt︱R语言调用深度学习架构系列引文 R语言︱H2o深度学习的一些R语言实 ...

随机推荐

  1. Android之事件分发

    网上总结的很详细了,有时间总结下做个笔记

  2. Unity3d 开发之 ulua 坑的总结

    相同的 lua 代码在安卓上能正常运行,但在 IOS 上可能不会正常运行而导致报红,崩溃等,我在使用 lua 编程时遇到的一些坑总结如下: 1. File.ReadAllText, 诸如以下代码在 i ...

  3. 关于服务器跨域问题(使用cors解决)

    1.配置cors依赖 pom中加入 <dependency> <groupId>com.thetransactioncompany</groupId> <ar ...

  4. Apache和Nginx的对比

    Apache与Nginx的优缺点比较 1.nginx相对于apache的优点: 轻量级,同样起web 服务,比apache 占用更少的内存及资源 抗并发,nginx 处理请求是异步非阻塞的,而apac ...

  5. maven 阿里云节点,速度快

    修改maven根目录下的conf文件夹中的setting.xml文件. <mirrors> <mirror> <id>alimaven</id> < ...

  6. 20、手把手教你Extjs5(二十)模块Grid的多列表方案

    对于有很多字段的模块在一个grid中显示所有的字段,会显得很臃肿,对于不同的用户其侧重的字段类型也不尽相同,因此就有必要为Grid的列表设计多个方案.在这个自定义系统进行设计的时候,我已经将这部分内容 ...

  7. phpMyAdmin安装与配置(涉及LAMP配置)

    作者:zccst 安装一个phpMyAdmin还真麻烦,遇到很多问题.不过在解决过程中发现,PHP的水还真深,不是短时间可以看透的. 1,下载 建议去百度软件中心下载 2,使用 (1)解压后,复制配置 ...

  8. STM32F103 使用TIM3产生四路PWM

    STM32F103 使用TIM3产生四路PWM 程序如下: /********************************************************************* ...

  9. js prototype 和constructor

    1.function 和object 都有 constructor 和prototype 2. var a=new Animal() (animal 是function或Object) a 有 con ...

  10. ARM处理器简介

    参考: http://www.arm.com/zh/products/processors/instruction-set-architectures/index.php 1.ARM核演变图 2.AR ...