SlideShare a Scribd company logo
1 of 44
Download to read offline
Tensor Flow
Tensors: n-dimensional arrays
A sequence of tensor operations
Deep learning process are flows of tensors
Vector: 1-D tensor
Matrix: 2-D tensor
Can represent also many machine learning algorithms
A simple ReLU network
a1 b1 c1
a0 b0 c0
w
a1=a0wa,a+b0wb,a+c0wc,a
b1=a0wa,b+b0wb,b+c0wc,b
c1=a0wa,c+b0wb,c+c0wc,c
Apply relu(…) on a1, b1, c1
Slower approach
Per-neuron operation
More efficient approach
Matrix operation
As matrix operations
a0
a1 b1 c1
a0 b0 c0
w
. =
=relu( )
b0 c0 a1 b1 c1
a1a1
=relu( )b1b1
=relu( )c1c1
wa,a
wb,a
wc,a
wa,b
wb,b
wc,b
wa,c
wb,c
wc,c
With TensorFlow
a1 b1 c1
a0 b0 c0
w
out = tf.nn.relu(y)
y = tf.matmul(x, w)
x w
a0 . =b0 c0
wa,a
wb,a
wc,a
wa,b
wb,b
wc,b
wa,c
wb,c
wc,c
a1 b1 c1
=relu( )a1a1
=relu( )b1b1
=relu( )c1c1
import tensorflow as tf
Define Tensors
xa,a
xb,a
xc,a
xa,b
xb,b
xc,b
xa,c
xb,c
xc,c
w
Variable(<initial-value>,
name=<optional-name>)
w = tf.Variable(tf.random_normal([3, 3]), name='w')
import tensorflow as tf
y = tf.matmul(x, w)
relu_out = tf.nn.relu(y)
Variable stores the state of current execution
Others are operations
TensorFlow
Code so far defines a data flow graph
MatMul
ReLU
Variable
x
w = tf.Variable(tf.random_normal([3, 3]), name='w')
import tensorflow as tf
y = tf.matmul(x, w)
relu_out = tf.nn.relu(y)
Each variable corresponds to a
node in the graph, not the result
Can be confusing at the beginning
TensorFlow
Code so far defines a data flow graph
Needs to specify how we
want to execute the graph MatMul
ReLU
Variable
x
Session
Manage resource for graph execution
w = tf.Variable(tf.random_normal([3, 3]), name='w')
sess = tf.Session()
y = tf.matmul(x, w)
relu_out = tf.nn.relu(y)
import tensorflow as tf
result = sess.run(relu_out)
Graph
Fetch
Retrieve content from a node
w = tf.Variable(tf.random_normal([3, 3]), name='w')
sess = tf.Session()
y = tf.matmul(x, w)
relu_out = tf.nn.relu(y)
import tensorflow as tf
print sess.run(relu_out)
MatMul
ReLU
Variable
x
Fetch
We have assembled the pipes
Fetch the liquid
Graph
sess = tf.Session()
y = tf.matmul(x, w)
relu_out = tf.nn.relu(y)
import tensorflow as tf
print sess.run(relu_out)
sess.run(tf.initialize_all_variables())
w = tf.Variable(tf.random_normal([3, 3]), name='w')
InitializeVariable
Variable is an empty node
MatMul
ReLU
Variable
x
Fetch
Fill in the content of a
Variable node
Graph
sess = tf.Session()
y = tf.matmul(x, w)
relu_out = tf.nn.relu(y)
import tensorflow as tf
print sess.run(relu_out)
sess.run(tf.initialize_all_variables())
w = tf.Variable(tf.random_normal([3, 3]), name='w')
x = tf.placeholder("float", [1, 3])
Placeholder
How about x?
MatMul
ReLU
Variable
x
Fetch
placeholder(<data type>,
shape=<optional-shape>,
name=<optional-name>)
Its content will be fed
Graph
import numpy as np
import tensorflow as tf
sess = tf.Session()
x = tf.placeholder("float", [1, 3])
w = tf.Variable(tf.random_normal([3, 3]), name='w')
y = tf.matmul(x, w)
relu_out = tf.nn.relu(y)
sess.run(tf.initialize_all_variables())
print sess.run(relu_out, feed_dict={x:np.array([[1.0, 2.0, 3.0]])})
Feed
MatMul
ReLU
Variable
x
FetchPump liquid into the pipe
Feed
Session management
Needs to release resource after use
sess.close()
Common usage
with tf.Session() as sess:
…
Interactive
sess = InteractiveSession()
Prediction
import numpy as np
import tensorflow as tf
with tf.Session() as sess:
x = tf.placeholder("float", [1, 3])
w = tf.Variable(tf.random_normal([3, 3]), name='w')
relu_out = tf.nn.relu(tf.matmul(x, w))
softmax = tf.nn.softmax(relu_out)
sess.run(tf.initialize_all_variables())
print sess.run(softmax, feed_dict={x:np.array([[1.0, 2.0, 3.0]])})
Softmax
Make predictions for n targets that sum to 1
Prediction Difference
import numpy as np
import tensorflow as tf
with tf.Session() as sess:
x = tf.placeholder("float", [1, 3])
w = tf.Variable(tf.random_normal([3, 3]), name='w')
relu_out = tf.nn.relu(tf.matmul(x, w))
softmax = tf.nn.softmax(relu_out)
sess.run(tf.initialize_all_variables())
answer = np.array([[0.0, 1.0, 0.0]])
print answer - sess.run(softmax, feed_dict={x:np.array([[1.0, 2.0, 3.0]])})
Learn parameters: Loss
Define loss function
Loss function for softmax
softmax_cross_entropy_with_logits(
logits, labels, name=<optional-name>)
labels = tf.placeholder("float", [1, 3])
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
relu_out, labels, name='xentropy')
Learn parameters: Optimization
Gradient descent
class GradientDescentOptimizer
GradientDescentOptimizer(learning rate)
labels = tf.placeholder("float", [1, 3])
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
relu_out, labels, name='xentropy')
optimizer = tf.train.GradientDescentOptimizer(0.1)
train_op = optimizer.minimize(cross_entropy)
sess.run(train_op,
feed_dict= {x:np.array([[1.0, 2.0, 3.0]]), labels:answer})
learning rate = 0.1
Iterative update
labels = tf.placeholder("float", [1, 3])
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
relu_out, labels, name=‘xentropy')
optimizer = tf.train.GradientDescentOptimizer(0.1)
train_op = optimizer.minimize(cross_entropy)
for step in range(10):
sess.run(train_op,
feed_dict= {x:np.array([[1.0, 2.0, 3.0]]), labels:answer})
Gradient descent usually needs more than one step
Run multiple times
Add parameters for Softmax
…
softmax_w = tf.Variable(tf.random_normal([3, 3]))
logit = tf.matmul(relu_out, softmax_w)
softmax = tf.nn.softmax(logit)
…
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
logit, labels, name=‘xentropy')
…
Do not want to use only non-negative input
Softmax layer
Add biases
…
w = tf.Variable(tf.random_normal([3, 3]))
b = tf.Variable(tf.zeros([1, 3]))
relu_out = tf.nn.relu(tf.matmul(x, w) + b)
softmax_w = tf.Variable(tf.random_normal([3, 3]))
softmax_b = tf.Variable(tf.zeros([1, 3]))
logit = tf.matmul(relu_out, softmax_w) + softmax_b
softmax = tf.nn.softmax(logit)
…
Biases initialized to zero
Make it deep
…
x = tf.placeholder("float", [1, 3])
relu_out = x
num_layers = 2
for layer in range(num_layers):
w = tf.Variable(tf.random_normal([3, 3]))
b = tf.Variable(tf.zeros([1, 3]))
relu_out = tf.nn.relu(tf.matmul(relu_out, w) + b)
…
Add layers
Visualize the graph
TensorBoard
writer = tf.train.SummaryWriter(
'/tmp/tf_logs', sess.graph_def)
tensorboard --logdir=/tmp/tf_logs
Improve naming, improve visualization
name_scope(name)
Help specify hierarchical names
…
for layer in range(num_layers):
with tf.name_scope('relu'):
w = tf.Variable(tf.random_normal([3, 3]))
b = tf.Variable(tf.zeros([1, 3]))
relu_out = tf.nn.relu(tf.matmul(relu_out, w) + b)
…
Will help visualizer to better
understand hierarchical relation
Move to outside the loop?
Add name_scope for softmax
Before After
Add regularization to the loss
eg. L2 regularize on the Softmax layer parameters
…
l2reg = tf.reduce_sum(tf.square(softmax_w))
loss = cross_entropy + l2reg
train_op = optimizer.minimize(loss)
…
print sess.run(l2reg)
…
Add it to the loss
Automatic gradient calculation
Add a parallel path
Use activation as bias
Everything is a tensor
Residual learning
ILSVRC 2015 classification task winer
He et al. 2015
Visualize states
Add summaries
scalar_summary histogram_summary
merged_summaries = tf.merge_all_summaries()
results = sess.run([train_op, merged_summaries],
feed_dict=…)
writer.add_summary(results[1], step)
Save and load models
tf.train.Saver(…)
Default will associate with all variables
all_variables()
save(sess, save_path, …)
restore(sess, save_path, …)
Replace initialization
That’s why we need to run initialization
separately
Convolution
conv2d(input, filter, strides, padding,
use_cudnn_on_gpu=None, name=None)
LSTM
# Parameters of gates are concatenated into one multiply for efficiency.
c, h = array_ops.split(1, 2, state)
concat = linear([inputs, h], 4 * self._num_units,True)
# i = input_gate, j = new_input, f = forget_gate, o = output_gate
i, j, f, o = array_ops.split(1, 4, concat)
new_c = c * sigmoid(f + self._forget_bias) + sigmoid(i) * tanh(j)
new_h = tanh(new_c) * sigmoid(o)
BasicLSTMCell
Word2Vec with TensorFlow
# Look up embeddings for inputs.
embeddings = tf.Variable(
tf.random_uniform([vocabulary_size, embedding_size], -1.0, 1.0))
embed = tf.nn.embedding_lookup(embeddings, train_inputs)
# Construct the variables for the NCE loss
nce_weights = tf.Variable(
tf.truncated_normal([vocabulary_size, embedding_size],
stddev=1.0 / math.sqrt(embedding_size)))
nce_biases = tf.Variable(tf.zeros([vocabulary_size]))
# Compute the average NCE loss for the batch.
# tf.nce_loss automatically draws a new sample of the negative labels each
# time we evaluate the loss.
loss = tf.reduce_mean(
tf.nn.nce_loss(nce_weights, nce_biases, embed, train_labels,
num_sampled, vocabulary_size))
Reuse Pre-trained models
Image recognition
Inception-v3
military uniform (866): 0.647296
suit (794): 0.0477196
academic gown (896): 0.0232411
bow tie (817): 0.0157356
bolo tie (940): 0.0145024
Try it on your Android
github.com/tensorflow/tensorflow/tree/master/tensorflow/
examples/android
Uses a Google Inception model to classify camera
frames in real-time, displaying the top results in an
overlay on the camera image.
Tensorflow Android Camera Demo
github.com/nivwusquorum/tensorflow-deepq
Reinforcement Learning using Tensor Flow
github.com/asrivat1/DeepLearningVideoGames
Using Deep Q Networks to LearnVideo Game Strategies
github.com/woodrush/neural-art-tf
Neural art
github.com/sherjilozair/char-rnn-tensorflow
github.com/fchollet/keras
github.com/jazzsaxmafia/show_and_tell.tensorflow
github.com/jikexueyuanwiki/tensorflow-zh
Google Brain Residency Program
Learn to conduct deep learning research w/experts in our team
Fixed one-year employment with salary, benefits, ...
Interesting problems,TensorFlow, and access to
computational resources
Goal after one year is to have conducted several research
projects
New one year immersion program in deep learning research
Google Brain Residency Program
Who should apply?
People with BSc, MSc or PhD, ideally in CS,
mathematics or statistics
Completed coursework in calculus, linear
algebra, and probability, or equiv.
Motivated, hard working, and have a strong
interest in deep learning
Programming experience
Google Brain Residency Program
Program Application & Timeline
DEADLINE: January 15, 2016
Thanks for your attention!

More Related Content

What's hot

What's hot (20)

Tensor board
Tensor boardTensor board
Tensor board
 
Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2
 
Machine Learning - Introduction to Tensorflow
Machine Learning - Introduction to TensorflowMachine Learning - Introduction to Tensorflow
Machine Learning - Introduction to Tensorflow
 
30 分鐘學會實作 Python Feature Selection
30 分鐘學會實作 Python Feature Selection30 分鐘學會實作 Python Feature Selection
30 分鐘學會實作 Python Feature Selection
 
H2 o berkeleydltf
H2 o berkeleydltfH2 o berkeleydltf
H2 o berkeleydltf
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
 
Introduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and TensorflowIntroduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and Tensorflow
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your Browser
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
 
Python book
Python bookPython book
Python book
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
 
Dive Into PyTorch
Dive Into PyTorchDive Into PyTorch
Dive Into PyTorch
 
About RNN
About RNNAbout RNN
About RNN
 
About RNN
About RNNAbout RNN
About RNN
 
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
 

Viewers also liked

TensorFlow Serving, Deep Learning on Mobile, and Deeplearning4j on the JVM - ...
TensorFlow Serving, Deep Learning on Mobile, and Deeplearning4j on the JVM - ...TensorFlow Serving, Deep Learning on Mobile, and Deeplearning4j on the JVM - ...
TensorFlow Serving, Deep Learning on Mobile, and Deeplearning4j on the JVM - ...
Sam Putnam [Deep Learning]
 
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Andrew Gardner
 
Machine Learning Preliminaries and Math Refresher
Machine Learning Preliminaries and Math RefresherMachine Learning Preliminaries and Math Refresher
Machine Learning Preliminaries and Math Refresher
butest
 
Secure Because Math: A Deep-Dive on Machine Learning-Based Monitoring (#Secur...
Secure Because Math: A Deep-Dive on Machine Learning-Based Monitoring (#Secur...Secure Because Math: A Deep-Dive on Machine Learning-Based Monitoring (#Secur...
Secure Because Math: A Deep-Dive on Machine Learning-Based Monitoring (#Secur...
Alex Pinto
 

Viewers also liked (20)

Introduction to TensorFlow
Introduction to TensorFlowIntroduction to TensorFlow
Introduction to TensorFlow
 
Large Scale Deep Learning with TensorFlow
Large Scale Deep Learning with TensorFlow Large Scale Deep Learning with TensorFlow
Large Scale Deep Learning with TensorFlow
 
[系列活動] 一日搞懂生成式對抗網路
[系列活動] 一日搞懂生成式對抗網路[系列活動] 一日搞懂生成式對抗網路
[系列活動] 一日搞懂生成式對抗網路
 
[系列活動] Python爬蟲實戰
[系列活動] Python爬蟲實戰[系列活動] Python爬蟲實戰
[系列活動] Python爬蟲實戰
 
[系列活動] 無所不在的自然語言處理—基礎概念、技術與工具介紹
[系列活動] 無所不在的自然語言處理—基礎概念、技術與工具介紹[系列活動] 無所不在的自然語言處理—基礎概念、技術與工具介紹
[系列活動] 無所不在的自然語言處理—基礎概念、技術與工具介紹
 
Machine Intelligence at Google Scale: TensorFlow
Machine Intelligence at Google Scale: TensorFlowMachine Intelligence at Google Scale: TensorFlow
Machine Intelligence at Google Scale: TensorFlow
 
TensorFlow Serving, Deep Learning on Mobile, and Deeplearning4j on the JVM - ...
TensorFlow Serving, Deep Learning on Mobile, and Deeplearning4j on the JVM - ...TensorFlow Serving, Deep Learning on Mobile, and Deeplearning4j on the JVM - ...
TensorFlow Serving, Deep Learning on Mobile, and Deeplearning4j on the JVM - ...
 
Neural Networks with Google TensorFlow
Neural Networks with Google TensorFlowNeural Networks with Google TensorFlow
Neural Networks with Google TensorFlow
 
Introducing TensorFlow: The game changer in building "intelligent" applications
Introducing TensorFlow: The game changer in building "intelligent" applicationsIntroducing TensorFlow: The game changer in building "intelligent" applications
Introducing TensorFlow: The game changer in building "intelligent" applications
 
On-device machine learning: TensorFlow on Android
On-device machine learning: TensorFlow on AndroidOn-device machine learning: TensorFlow on Android
On-device machine learning: TensorFlow on Android
 
TensorFlow 深度學習講座
TensorFlow 深度學習講座TensorFlow 深度學習講座
TensorFlow 深度學習講座
 
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
 
Machine Learning Preliminaries and Math Refresher
Machine Learning Preliminaries and Math RefresherMachine Learning Preliminaries and Math Refresher
Machine Learning Preliminaries and Math Refresher
 
Secure Because Math: A Deep-Dive on Machine Learning-Based Monitoring (#Secur...
Secure Because Math: A Deep-Dive on Machine Learning-Based Monitoring (#Secur...Secure Because Math: A Deep-Dive on Machine Learning-Based Monitoring (#Secur...
Secure Because Math: A Deep-Dive on Machine Learning-Based Monitoring (#Secur...
 
Machine Learning without the Math: An overview of Machine Learning
Machine Learning without the Math: An overview of Machine LearningMachine Learning without the Math: An overview of Machine Learning
Machine Learning without the Math: An overview of Machine Learning
 
[系列活動] 資料探勘速遊
[系列活動] 資料探勘速遊[系列活動] 資料探勘速遊
[系列活動] 資料探勘速遊
 
qconsf 2013: Top 10 Performance Gotchas for scaling in-memory Algorithms - Sr...
qconsf 2013: Top 10 Performance Gotchas for scaling in-memory Algorithms - Sr...qconsf 2013: Top 10 Performance Gotchas for scaling in-memory Algorithms - Sr...
qconsf 2013: Top 10 Performance Gotchas for scaling in-memory Algorithms - Sr...
 
02 math essentials
02 math essentials02 math essentials
02 math essentials
 
Kafka Summit SF Apr 26 2016 - Generating Real-time Recommendations with NiFi,...
Kafka Summit SF Apr 26 2016 - Generating Real-time Recommendations with NiFi,...Kafka Summit SF Apr 26 2016 - Generating Real-time Recommendations with NiFi,...
Kafka Summit SF Apr 26 2016 - Generating Real-time Recommendations with NiFi,...
 
Big Data Spain - Nov 17 2016 - Madrid Continuously Deploy Spark ML and Tensor...
Big Data Spain - Nov 17 2016 - Madrid Continuously Deploy Spark ML and Tensor...Big Data Spain - Nov 17 2016 - Madrid Continuously Deploy Spark ML and Tensor...
Big Data Spain - Nov 17 2016 - Madrid Continuously Deploy Spark ML and Tensor...
 

Similar to Google TensorFlow Tutorial

Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docx
lauracallander
 
Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlow
Sri Ambati
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
SALU18
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
Johan Tibell
 

Similar to Google TensorFlow Tutorial (20)

Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITians
 
Font classification with 5 deep learning models using tensor flow
Font classification with 5 deep learning models using tensor flowFont classification with 5 deep learning models using tensor flow
Font classification with 5 deep learning models using tensor flow
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docx
 
What is TensorFlow and why do we use it
What is TensorFlow and why do we use itWhat is TensorFlow and why do we use it
What is TensorFlow and why do we use it
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
 
TensorFlow Tutorial.pdf
TensorFlow Tutorial.pdfTensorFlow Tutorial.pdf
TensorFlow Tutorial.pdf
 
Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019
 
Introduction to TensorFlow
Introduction to TensorFlowIntroduction to TensorFlow
Introduction to TensorFlow
 
Theano vs TensorFlow | Edureka
Theano vs TensorFlow | EdurekaTheano vs TensorFlow | Edureka
Theano vs TensorFlow | Edureka
 
Fp in scala part 2
Fp in scala part 2Fp in scala part 2
Fp in scala part 2
 
Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlow
 
Neural networks with python
Neural networks with pythonNeural networks with python
Neural networks with python
 
Introduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlowIntroduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlow
 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsIntro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.js
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Deep learning with C++ - an introduction to tiny-dnn
Deep learning with C++  - an introduction to tiny-dnnDeep learning with C++  - an introduction to tiny-dnn
Deep learning with C++ - an introduction to tiny-dnn
 

More from 台灣資料科學年會

[2018 台灣人工智慧學校校友年會] 產業經驗分享: 如何用最少的訓練樣本,得到最好的深度學習影像分析結果,減少一半人力,提升一倍品質 / 李明達
[2018 台灣人工智慧學校校友年會] 產業經驗分享: 如何用最少的訓練樣本,得到最好的深度學習影像分析結果,減少一半人力,提升一倍品質 / 李明達[2018 台灣人工智慧學校校友年會] 產業經驗分享: 如何用最少的訓練樣本,得到最好的深度學習影像分析結果,減少一半人力,提升一倍品質 / 李明達
[2018 台灣人工智慧學校校友年會] 產業經驗分享: 如何用最少的訓練樣本,得到最好的深度學習影像分析結果,減少一半人力,提升一倍品質 / 李明達
台灣資料科學年會
 

More from 台灣資料科學年會 (20)

[台灣人工智慧學校] 人工智慧技術發展與應用
[台灣人工智慧學校] 人工智慧技術發展與應用[台灣人工智慧學校] 人工智慧技術發展與應用
[台灣人工智慧學校] 人工智慧技術發展與應用
 
[台灣人工智慧學校] 執行長報告
[台灣人工智慧學校] 執行長報告[台灣人工智慧學校] 執行長報告
[台灣人工智慧學校] 執行長報告
 
[台灣人工智慧學校] 工業 4.0 與智慧製造的發展趨勢與挑戰
[台灣人工智慧學校] 工業 4.0 與智慧製造的發展趨勢與挑戰[台灣人工智慧學校] 工業 4.0 與智慧製造的發展趨勢與挑戰
[台灣人工智慧學校] 工業 4.0 與智慧製造的發展趨勢與挑戰
 
[台灣人工智慧學校] 開創台灣產業智慧轉型的新契機
[台灣人工智慧學校] 開創台灣產業智慧轉型的新契機[台灣人工智慧學校] 開創台灣產業智慧轉型的新契機
[台灣人工智慧學校] 開創台灣產業智慧轉型的新契機
 
[台灣人工智慧學校] 開創台灣產業智慧轉型的新契機
[台灣人工智慧學校] 開創台灣產業智慧轉型的新契機[台灣人工智慧學校] 開創台灣產業智慧轉型的新契機
[台灣人工智慧學校] 開創台灣產業智慧轉型的新契機
 
[台灣人工智慧學校] 台北總校第三期結業典禮 - 執行長談話
[台灣人工智慧學校] 台北總校第三期結業典禮 - 執行長談話[台灣人工智慧學校] 台北總校第三期結業典禮 - 執行長談話
[台灣人工智慧學校] 台北總校第三期結業典禮 - 執行長談話
 
[TOxAIA台中分校] AI 引爆新工業革命,智慧機械首都台中轉型論壇
[TOxAIA台中分校] AI 引爆新工業革命,智慧機械首都台中轉型論壇[TOxAIA台中分校] AI 引爆新工業革命,智慧機械首都台中轉型論壇
[TOxAIA台中分校] AI 引爆新工業革命,智慧機械首都台中轉型論壇
 
[TOxAIA台中分校] 2019 台灣數位轉型 與產業升級趨勢觀察
[TOxAIA台中分校] 2019 台灣數位轉型 與產業升級趨勢觀察 [TOxAIA台中分校] 2019 台灣數位轉型 與產業升級趨勢觀察
[TOxAIA台中分校] 2019 台灣數位轉型 與產業升級趨勢觀察
 
[TOxAIA台中分校] 智慧製造成真! 產線導入AI的致勝關鍵
[TOxAIA台中分校] 智慧製造成真! 產線導入AI的致勝關鍵[TOxAIA台中分校] 智慧製造成真! 產線導入AI的致勝關鍵
[TOxAIA台中分校] 智慧製造成真! 產線導入AI的致勝關鍵
 
[台灣人工智慧學校] 從經濟學看人工智慧產業應用
[台灣人工智慧學校] 從經濟學看人工智慧產業應用[台灣人工智慧學校] 從經濟學看人工智慧產業應用
[台灣人工智慧學校] 從經濟學看人工智慧產業應用
 
[台灣人工智慧學校] 台中分校第二期開學典禮 - 執行長報告
[台灣人工智慧學校] 台中分校第二期開學典禮 - 執行長報告[台灣人工智慧學校] 台中分校第二期開學典禮 - 執行長報告
[台灣人工智慧學校] 台中分校第二期開學典禮 - 執行長報告
 
台灣人工智慧學校成果發表會
台灣人工智慧學校成果發表會台灣人工智慧學校成果發表會
台灣人工智慧學校成果發表會
 
[台中分校] 第一期結業典禮 - 執行長談話
[台中分校] 第一期結業典禮 - 執行長談話[台中分校] 第一期結業典禮 - 執行長談話
[台中分校] 第一期結業典禮 - 執行長談話
 
[TOxAIA新竹分校] 工業4.0潛力新應用! 多模式對話機器人
[TOxAIA新竹分校] 工業4.0潛力新應用! 多模式對話機器人[TOxAIA新竹分校] 工業4.0潛力新應用! 多模式對話機器人
[TOxAIA新竹分校] 工業4.0潛力新應用! 多模式對話機器人
 
[TOxAIA新竹分校] AI整合是重點! 竹科的關鍵轉型思維
[TOxAIA新竹分校] AI整合是重點! 竹科的關鍵轉型思維[TOxAIA新竹分校] AI整合是重點! 竹科的關鍵轉型思維
[TOxAIA新竹分校] AI整合是重點! 竹科的關鍵轉型思維
 
[TOxAIA新竹分校] 2019 台灣數位轉型與產業升級趨勢觀察
[TOxAIA新竹分校] 2019 台灣數位轉型與產業升級趨勢觀察[TOxAIA新竹分校] 2019 台灣數位轉型與產業升級趨勢觀察
[TOxAIA新竹分校] 2019 台灣數位轉型與產業升級趨勢觀察
 
[TOxAIA新竹分校] 深度學習與Kaggle實戰
[TOxAIA新竹分校] 深度學習與Kaggle實戰[TOxAIA新竹分校] 深度學習與Kaggle實戰
[TOxAIA新竹分校] 深度學習與Kaggle實戰
 
[台灣人工智慧學校] Bridging AI to Precision Agriculture through IoT
[台灣人工智慧學校] Bridging AI to Precision Agriculture through IoT[台灣人工智慧學校] Bridging AI to Precision Agriculture through IoT
[台灣人工智慧學校] Bridging AI to Precision Agriculture through IoT
 
[2018 台灣人工智慧學校校友年會] 產業經驗分享: 如何用最少的訓練樣本,得到最好的深度學習影像分析結果,減少一半人力,提升一倍品質 / 李明達
[2018 台灣人工智慧學校校友年會] 產業經驗分享: 如何用最少的訓練樣本,得到最好的深度學習影像分析結果,減少一半人力,提升一倍品質 / 李明達[2018 台灣人工智慧學校校友年會] 產業經驗分享: 如何用最少的訓練樣本,得到最好的深度學習影像分析結果,減少一半人力,提升一倍品質 / 李明達
[2018 台灣人工智慧學校校友年會] 產業經驗分享: 如何用最少的訓練樣本,得到最好的深度學習影像分析結果,減少一半人力,提升一倍品質 / 李明達
 
[2018 台灣人工智慧學校校友年會] 啟動物聯網新關鍵 - 未來由你「喚」醒 / 沈品勳
[2018 台灣人工智慧學校校友年會] 啟動物聯網新關鍵 - 未來由你「喚」醒 / 沈品勳[2018 台灣人工智慧學校校友年會] 啟動物聯網新關鍵 - 未來由你「喚」醒 / 沈品勳
[2018 台灣人工智慧學校校友年會] 啟動物聯網新關鍵 - 未來由你「喚」醒 / 沈品勳
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Google TensorFlow Tutorial

  • 1. Tensor Flow Tensors: n-dimensional arrays A sequence of tensor operations Deep learning process are flows of tensors Vector: 1-D tensor Matrix: 2-D tensor Can represent also many machine learning algorithms
  • 2. A simple ReLU network a1 b1 c1 a0 b0 c0 w a1=a0wa,a+b0wb,a+c0wc,a b1=a0wa,b+b0wb,b+c0wc,b c1=a0wa,c+b0wb,c+c0wc,c Apply relu(…) on a1, b1, c1 Slower approach Per-neuron operation More efficient approach Matrix operation
  • 3. As matrix operations a0 a1 b1 c1 a0 b0 c0 w . = =relu( ) b0 c0 a1 b1 c1 a1a1 =relu( )b1b1 =relu( )c1c1 wa,a wb,a wc,a wa,b wb,b wc,b wa,c wb,c wc,c
  • 4. With TensorFlow a1 b1 c1 a0 b0 c0 w out = tf.nn.relu(y) y = tf.matmul(x, w) x w a0 . =b0 c0 wa,a wb,a wc,a wa,b wb,b wc,b wa,c wb,c wc,c a1 b1 c1 =relu( )a1a1 =relu( )b1b1 =relu( )c1c1 import tensorflow as tf
  • 5. Define Tensors xa,a xb,a xc,a xa,b xb,b xc,b xa,c xb,c xc,c w Variable(<initial-value>, name=<optional-name>) w = tf.Variable(tf.random_normal([3, 3]), name='w') import tensorflow as tf y = tf.matmul(x, w) relu_out = tf.nn.relu(y) Variable stores the state of current execution Others are operations
  • 6. TensorFlow Code so far defines a data flow graph MatMul ReLU Variable x w = tf.Variable(tf.random_normal([3, 3]), name='w') import tensorflow as tf y = tf.matmul(x, w) relu_out = tf.nn.relu(y) Each variable corresponds to a node in the graph, not the result Can be confusing at the beginning
  • 7. TensorFlow Code so far defines a data flow graph Needs to specify how we want to execute the graph MatMul ReLU Variable x Session Manage resource for graph execution w = tf.Variable(tf.random_normal([3, 3]), name='w') sess = tf.Session() y = tf.matmul(x, w) relu_out = tf.nn.relu(y) import tensorflow as tf result = sess.run(relu_out)
  • 8. Graph Fetch Retrieve content from a node w = tf.Variable(tf.random_normal([3, 3]), name='w') sess = tf.Session() y = tf.matmul(x, w) relu_out = tf.nn.relu(y) import tensorflow as tf print sess.run(relu_out) MatMul ReLU Variable x Fetch We have assembled the pipes Fetch the liquid
  • 9. Graph sess = tf.Session() y = tf.matmul(x, w) relu_out = tf.nn.relu(y) import tensorflow as tf print sess.run(relu_out) sess.run(tf.initialize_all_variables()) w = tf.Variable(tf.random_normal([3, 3]), name='w') InitializeVariable Variable is an empty node MatMul ReLU Variable x Fetch Fill in the content of a Variable node
  • 10. Graph sess = tf.Session() y = tf.matmul(x, w) relu_out = tf.nn.relu(y) import tensorflow as tf print sess.run(relu_out) sess.run(tf.initialize_all_variables()) w = tf.Variable(tf.random_normal([3, 3]), name='w') x = tf.placeholder("float", [1, 3]) Placeholder How about x? MatMul ReLU Variable x Fetch placeholder(<data type>, shape=<optional-shape>, name=<optional-name>) Its content will be fed
  • 11. Graph import numpy as np import tensorflow as tf sess = tf.Session() x = tf.placeholder("float", [1, 3]) w = tf.Variable(tf.random_normal([3, 3]), name='w') y = tf.matmul(x, w) relu_out = tf.nn.relu(y) sess.run(tf.initialize_all_variables()) print sess.run(relu_out, feed_dict={x:np.array([[1.0, 2.0, 3.0]])}) Feed MatMul ReLU Variable x FetchPump liquid into the pipe Feed
  • 12. Session management Needs to release resource after use sess.close() Common usage with tf.Session() as sess: … Interactive sess = InteractiveSession()
  • 13. Prediction import numpy as np import tensorflow as tf with tf.Session() as sess: x = tf.placeholder("float", [1, 3]) w = tf.Variable(tf.random_normal([3, 3]), name='w') relu_out = tf.nn.relu(tf.matmul(x, w)) softmax = tf.nn.softmax(relu_out) sess.run(tf.initialize_all_variables()) print sess.run(softmax, feed_dict={x:np.array([[1.0, 2.0, 3.0]])}) Softmax Make predictions for n targets that sum to 1
  • 14. Prediction Difference import numpy as np import tensorflow as tf with tf.Session() as sess: x = tf.placeholder("float", [1, 3]) w = tf.Variable(tf.random_normal([3, 3]), name='w') relu_out = tf.nn.relu(tf.matmul(x, w)) softmax = tf.nn.softmax(relu_out) sess.run(tf.initialize_all_variables()) answer = np.array([[0.0, 1.0, 0.0]]) print answer - sess.run(softmax, feed_dict={x:np.array([[1.0, 2.0, 3.0]])})
  • 15. Learn parameters: Loss Define loss function Loss function for softmax softmax_cross_entropy_with_logits( logits, labels, name=<optional-name>) labels = tf.placeholder("float", [1, 3]) cross_entropy = tf.nn.softmax_cross_entropy_with_logits( relu_out, labels, name='xentropy')
  • 16. Learn parameters: Optimization Gradient descent class GradientDescentOptimizer GradientDescentOptimizer(learning rate) labels = tf.placeholder("float", [1, 3]) cross_entropy = tf.nn.softmax_cross_entropy_with_logits( relu_out, labels, name='xentropy') optimizer = tf.train.GradientDescentOptimizer(0.1) train_op = optimizer.minimize(cross_entropy) sess.run(train_op, feed_dict= {x:np.array([[1.0, 2.0, 3.0]]), labels:answer}) learning rate = 0.1
  • 17. Iterative update labels = tf.placeholder("float", [1, 3]) cross_entropy = tf.nn.softmax_cross_entropy_with_logits( relu_out, labels, name=‘xentropy') optimizer = tf.train.GradientDescentOptimizer(0.1) train_op = optimizer.minimize(cross_entropy) for step in range(10): sess.run(train_op, feed_dict= {x:np.array([[1.0, 2.0, 3.0]]), labels:answer}) Gradient descent usually needs more than one step Run multiple times
  • 18. Add parameters for Softmax … softmax_w = tf.Variable(tf.random_normal([3, 3])) logit = tf.matmul(relu_out, softmax_w) softmax = tf.nn.softmax(logit) … cross_entropy = tf.nn.softmax_cross_entropy_with_logits( logit, labels, name=‘xentropy') … Do not want to use only non-negative input Softmax layer
  • 19. Add biases … w = tf.Variable(tf.random_normal([3, 3])) b = tf.Variable(tf.zeros([1, 3])) relu_out = tf.nn.relu(tf.matmul(x, w) + b) softmax_w = tf.Variable(tf.random_normal([3, 3])) softmax_b = tf.Variable(tf.zeros([1, 3])) logit = tf.matmul(relu_out, softmax_w) + softmax_b softmax = tf.nn.softmax(logit) … Biases initialized to zero
  • 20. Make it deep … x = tf.placeholder("float", [1, 3]) relu_out = x num_layers = 2 for layer in range(num_layers): w = tf.Variable(tf.random_normal([3, 3])) b = tf.Variable(tf.zeros([1, 3])) relu_out = tf.nn.relu(tf.matmul(relu_out, w) + b) … Add layers
  • 21. Visualize the graph TensorBoard writer = tf.train.SummaryWriter( '/tmp/tf_logs', sess.graph_def) tensorboard --logdir=/tmp/tf_logs
  • 22. Improve naming, improve visualization name_scope(name) Help specify hierarchical names … for layer in range(num_layers): with tf.name_scope('relu'): w = tf.Variable(tf.random_normal([3, 3])) b = tf.Variable(tf.zeros([1, 3])) relu_out = tf.nn.relu(tf.matmul(relu_out, w) + b) … Will help visualizer to better understand hierarchical relation Move to outside the loop?
  • 23. Add name_scope for softmax Before After
  • 24. Add regularization to the loss eg. L2 regularize on the Softmax layer parameters … l2reg = tf.reduce_sum(tf.square(softmax_w)) loss = cross_entropy + l2reg train_op = optimizer.minimize(loss) … print sess.run(l2reg) … Add it to the loss Automatic gradient calculation
  • 26. Use activation as bias Everything is a tensor
  • 27. Residual learning ILSVRC 2015 classification task winer He et al. 2015
  • 28. Visualize states Add summaries scalar_summary histogram_summary merged_summaries = tf.merge_all_summaries() results = sess.run([train_op, merged_summaries], feed_dict=…) writer.add_summary(results[1], step)
  • 29. Save and load models tf.train.Saver(…) Default will associate with all variables all_variables() save(sess, save_path, …) restore(sess, save_path, …) Replace initialization That’s why we need to run initialization separately
  • 30. Convolution conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, name=None)
  • 31. LSTM # Parameters of gates are concatenated into one multiply for efficiency. c, h = array_ops.split(1, 2, state) concat = linear([inputs, h], 4 * self._num_units,True) # i = input_gate, j = new_input, f = forget_gate, o = output_gate i, j, f, o = array_ops.split(1, 4, concat) new_c = c * sigmoid(f + self._forget_bias) + sigmoid(i) * tanh(j) new_h = tanh(new_c) * sigmoid(o) BasicLSTMCell
  • 32. Word2Vec with TensorFlow # Look up embeddings for inputs. embeddings = tf.Variable( tf.random_uniform([vocabulary_size, embedding_size], -1.0, 1.0)) embed = tf.nn.embedding_lookup(embeddings, train_inputs) # Construct the variables for the NCE loss nce_weights = tf.Variable( tf.truncated_normal([vocabulary_size, embedding_size], stddev=1.0 / math.sqrt(embedding_size))) nce_biases = tf.Variable(tf.zeros([vocabulary_size])) # Compute the average NCE loss for the batch. # tf.nce_loss automatically draws a new sample of the negative labels each # time we evaluate the loss. loss = tf.reduce_mean( tf.nn.nce_loss(nce_weights, nce_biases, embed, train_labels, num_sampled, vocabulary_size))
  • 33. Reuse Pre-trained models Image recognition Inception-v3 military uniform (866): 0.647296 suit (794): 0.0477196 academic gown (896): 0.0232411 bow tie (817): 0.0157356 bolo tie (940): 0.0145024
  • 34. Try it on your Android github.com/tensorflow/tensorflow/tree/master/tensorflow/ examples/android Uses a Google Inception model to classify camera frames in real-time, displaying the top results in an overlay on the camera image. Tensorflow Android Camera Demo
  • 36. github.com/asrivat1/DeepLearningVideoGames Using Deep Q Networks to LearnVideo Game Strategies
  • 42. Google Brain Residency Program Learn to conduct deep learning research w/experts in our team Fixed one-year employment with salary, benefits, ... Interesting problems,TensorFlow, and access to computational resources Goal after one year is to have conducted several research projects New one year immersion program in deep learning research
  • 43. Google Brain Residency Program Who should apply? People with BSc, MSc or PhD, ideally in CS, mathematics or statistics Completed coursework in calculus, linear algebra, and probability, or equiv. Motivated, hard working, and have a strong interest in deep learning Programming experience
  • 44. Google Brain Residency Program Program Application & Timeline DEADLINE: January 15, 2016 Thanks for your attention!