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. mysql用存储过程插入百万条数据, 及查询优化

    查看所有存储过程: show procedure status; 查看详细存储过程 ptest: show create procedure ptest; 存储过程插入数据: create table ...

  2. iOS8学习笔记2--autolayout

    iOS支持的设备如今已经具有了很多的尺寸,针对这些不同的尺寸每一个都做一个独立的APP肯定是不现实的,于是苹果在iOS8之后推出了autolayout和sizeclass,同时还有VFL界面设计语言 ...

  3. css(一)-- 概述以及引入方式

    概述 层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言.CSS不仅可 ...

  4. Photoshop 画基本图形

    作者:zccst 1,画三角形 按下“U”选择“多边形工具”(是个六边形的图标),在上方的菜单栏中的“边”后面输入“3”,然后在画布中拖动就是三角形了,画好后按下CTRL+ENTER键转化成选区,然后 ...

  5. php部分--文件操作

    php中的文件指的是文件和文件夹,不是单指文件. 1.判断文件(判断是文件还是文件夹) 找文件,输出结果为file,代表的是文件. var_dump(filetype("./aa.txt&q ...

  6. 网络IO模型

    同步(synchronous) IO和异步(asynchronous) IO,阻塞(blocking) IO和非阻塞(non-blocking)IO分别是什么,到底有什么区别?这个问题其实不同的人给出 ...

  7. STM32F412应用开发笔记之八:迪文串口屏显示驱动

    迪文的显示屏使用起来比较方便,其使用串口通讯,即可支持RS232,又可以支持TTL电平.在NUCLEO-F412ZG实验板上,USART2已经引到了CN9上,我们就利用USART2来实现与迪文串口屏的 ...

  8. .NET运行机制

    .NET运行机制   .NET框架是一个多语言组件开发和执行环境,它提供了一个跨语言的统一编程环境..NET框架的目的是便于开发人员更容易地建立Web应用程序和Web服务,使得Internet上的各应 ...

  9. 谈谈NIO和IO

    Channel,Buffer 和 Selector 构成了核心的API. 其它组件,如Pipe和FileLock,只不过是与三个核心组件共同使用的工具类. Channel和Buffer 基本上,所有的 ...

  10. iOS 操作系统整体架构层次讲解

    iOS的系统架构分为四个层次:核心操作系统层(Core OS layer).核心服务层(Core Services layer).媒体层(Media layer)和可触摸层(Cocoa Touch l ...