CS20SI Tensorflow for Deeplearning课程笔记(一)
来源:互联网 发布:linux 执行权限 编辑:程序博客网 时间:2024/06/06 11:36
一、 课程目标
- 理解TF的计算图方法
- 探索TF的内置函数
- 学会怎么去构建和组织最好的模型去做深度学习项目
二、书籍
- TensorFlow for Machine Intelligence (TFFMI)
- Hands-On Machine Learning with Scikit-Learn and TensorFlow. Chapter 9
Up and running with TensorFlow - Fundamentals of Deep Learning. Chapter 3: Implementing Neural Networks in TensorFlow (FODL)
书籍容易过时,推荐tensorflow官网
三、 简化版的Tensorflow
- TF Learn (tf.contrib.learn)
- TF Slim (tf.contrib.slim):
- 高级版 API: Keras, TFLearn, Pretty Tensor
四、Graphs and Sessions
1. tensor
一种n维的矩阵
0-d tensor: scalar (number)
1-d tensor: vector
2-d tensor: matrix
and so on
2. Data Flow Graphs
计算a的值的方式
import tensorflow as tfa = tf.add(3, 5)# with clause takes care# of sess.close()with tf.Session() as sess: print sess.run(a)
数据流图如下所示
3. tf.Session()
主要用于执行需要计算的tensor。
x = 2y = 3op1 = tf.add(x, y)op2 = tf.mul(x, y)op3 = tf.pow(op2, op1)with tf.Session() as sess: op3 = sess.run(op3)
可以将图分成几部分,然后并行地计算在CPU,GPU上,如下图所示
4. tf.Graph()
添加一个运算给图,并将其设为默认图
g = tf.Graph()with g.as_default(): a = 3 b = 5 x = tf.add(a, b) sess = tf.Session(graph=g) # session is run on the graph g# run session sess.close()
获取默认的图
g = tf.get_default_graph()
不要将默认的图和用户创建的图混合在一起,如下情况会报错
g = tf.Graph()# add ops to the default grapha = tf.constant(3)# add ops to the user created graphwith g.as_default(): b = tf.constant(5)#Prone to errors
正确的使用方式
g1 = tf.get_default_graph()g2 = tf.Graph()# add ops to the default graphwith g1.as_default(): a = tf.Constant(3)# add ops to the user created graph with g2.as_default():b = tf.Constant(5)
为什么使用Graph?
1. Save computation (only run subgraphs that lead to the values you want to fetch)
2. Break computation into small, differential pieces to facilitates auto-differentiation
3. Facilitate distributed computation, spread the work across multiple CPUs, GPUs, or devices
4. Many common machine learning models are commonly taught and visualized as directed graphs already
阅读全文
0 0
- CS20SI Tensorflow for Deeplearning课程笔记(一)
- CS20SI Tensorflow for Deeplearning课程笔记(二)
- CS20SI Tensorflow for Deeplearning课程笔记(三)
- CS20SI Tensorflow for Deeplearning课程笔记(四) word2vec with NCE loss and visualize the embeddings
- CS20si课程笔记1:Tensorflow Introduction
- cs20si: tensorflow for research 学习笔记1
- 斯坦福CS20SI:基于Tensorflow的深度学习研究课程笔记,Lecture note2:TensorFlow Ops
- [翻译]斯坦福CS20SI:基于Tensorflow的深度学习研究课程笔记,Lecture note 1: Introduction to TensorFlow
- 斯坦福CS20SI:基于Tensorflow的深度学习研究课程笔记,Lecture note3:TensorFlow上的线性回归和逻辑回归
- 吴恩达Deeplearning.ai专项课程笔记(一)-- 神经网络基础
- Tensorflow | 斯坦福cs20si | lecture1
- TensorFlow学习之CS20SI 之一
- deeplearning.ai课程笔记(1)
- 吴恩达deeplearning.ai课程系列笔记01
- 吴恩达deeplearning.ai课程系列笔记02
- 吴恩达deeplearning.ai课程系列笔记03
- 吴恩达deeplearning.ai课程系列笔记04
- 吴恩达deeplearning.ai课程系列笔记06
- Unity3d实现扭动挤压浏览效果
- Java 多线程编程
- tp5改写跳转提示页面
- HDOJ 2094&&map水过
- 异常com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException
- CS20SI Tensorflow for Deeplearning课程笔记(一)
- 感知机算法
- 单片机实验4
- HttpUtil
- document.ready和onload的区别
- 线程、进程间的通信方式
- 【Errcode:13-Permission denied】mysqlbinlog:File'/var/log/mysql/mysql-bin.000001' not found解决方案
- POJ2586(贪心)
- Spring Security实现动态权限管理