SlideShare a Scribd company logo
1 of 79
Download to read offline
Gentlest Intro to Tensorflow (Part 2)
Khor Soon Hin, @neth_6, re:Culture
In collaboration with Sam & Edmund
Next Steps
● Review of Tensorflow
○ In illustrations
○ tf.placeholder & feed
○ Training process
● Tensorboard: Visualize cost, W, b
● Training batch size: Stochastic/Mini-batch/Full-batch
Quick Review
Given house size, use machine learning to predict house price
Quick Review
House Size, sqm
House Price, $
Quick Review
House Size, sqm
House Price, $
Collect (‘generate fake’) data
y (house price) = 2.x (house size)
Quick Review
House Size, sqm
House Price, $
Model using linear regression
y = W.x + b
Quick Review
House Size, sqm
House Price, $
Model using linear regression
y = W.x + b
Learn the best W, b
Quick Review
House Size, sqm
House Price, $
Model using linear regression
y = W.x + b
Learn the best W, b
by reducing cost
Quick Review
House Size, sqm
House Price, $
Model using linear regression
y = W.x + b
Best W, b helps
make best predictionPrediction!
Any house size!
Quick Review
Modeling linear regression in Tensorflow
Tensorflow Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
Tensorflow Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
prediction
Tensorflow Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
Goal: Trainprediction
Tensorflow Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
Goal: Train
How: Minimizing actual vs. prediction
prediction
Tensorflow Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
Goal: Train
How: Minimizing actual vs. prediction
prediction
Train: tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
W, b
Init with some values
What is Train?
What is Train?
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
Init with some values
What is Train?
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Init with some values
Actual Datapoints
x
y_
What is Train?
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Init with some values
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
What is Train?
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
What is Train?
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
One training step
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
What is Train?
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
What is Train?
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
What is Train?
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
Repeat N steps
OR
Until Cost reaches desired value
Creating Tensorflow Graph
Tensorflow Graph
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
Model in TF!
Tensorflow Graph
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Define as tf.Variable
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
Tensorflow Graph
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Define as tf.placeholder
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
Tensorflow Graph: tf.Variable (Enhance visualization)
# tf.Variable for holding variables we want to learn, W, b
W = tf.Variable(tf.zeros([1,1]), name=‘W’)
b = tf.Variable(tf.zeros([1]), name=‘b’)
NOTE: Without name=XXX, the variables will be assigned names like Variable_0, Variable_1, etc.
1 feature, house size
1 output, house price
Tensorflow Graph: tf.placeholder (Enhance visualization)
# tf.placeholder for actual data, e.g., house size (x), house price (y_)
x = tf.placeholder(tf.float32, [None, 1], name=‘x’)
y_ = tf.placeholder(tf.float32, [None, 1], name=‘y_’)
NOTE: Without name=XXX, the placeholders will be assigned names like Placeholder_0, Placeholder_1, etc.
1 feature, house size
1 output, house price
Tensorflow Graph: Model (Enhance visualization)
# Model linear regression y = Wx + b
with tf.name_scope("Wx_b") as scope:
product = tf.matmul(x,W)
y = product + b
NOTE: With scope, the all definitions under it, will appear as a black-box that is expandable!
Tensorflow Graph: Cost (Enhance visualization)
# Cost function: Least-squared difference
with tf.name_scope("cost") as scope:
cost = tf.reduce_mean(tf.square(y_-y))
Tensorflow Graph: Train (Enhance visualization)
# Train step
with tf.name_scope("train") as scope:
train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
Tensorboard
Two Main Components
● Summary
○ Mark data we want to collect
■ W, b, cost
● Writer
○ Write data collected to event file
Tensorflow Summary: Scalar
tf.scalar_summary
# cost is single-dimension so
# mark it as data to be collected using scalar_summary
cost = tf.reduce_mean(tf.square(y_-y))
cost_sum = tf.scalar_summary("cost", cost)
Tensorflow Summary: Histogram
tf.histogram_summary
# W and b can be multi-dimensional so
# mark them as data to be collected using histogram_summary
W = tf.Variable(tf.zeros([1,1]), name="W")
W_hist = tf.histogram_summary("weights", W)
b = tf.Variable(tf.zeros([1]), name="b")
b_hist = tf.histogram_summary("biases", b)
Tensorflow Summary: Merge
tf.merge_all_summaries
merged = tf.merge_all_summaries()
tf.merge_summary
merged = tf.merge_summary([W_hist, b_hist, cost_sum])
Tensorflow Writer
# The specified log directory will be:
# * Created if it does not exist
# * If exist and not empty data is merged
# sess.graph_def will enable Tensorflow to draw graph representation
# for network
writer = tf.train.SummaryWriter("/event_log_dir", sess.graph_def)
Tensorflow Writer: When to Record Data
# NOTE: Train using #steps
for i in steps:
...
# NOTE: Write summary every 10 samples
if i % 10 == 0:
all_feed = { x: all_xs, y_: all_ys }
# NOTE:
# * merged is our merged summary name
# * feed is the batch of all x, y data points, to calculate TOTAL cost
result = sess.run(merged, feed_dict=all_feed)
writer.add_summary(result, i)
...
Start Tensorboard Server
NOTE: Single line
python /usr/local/lib/python2.7/dist-packages/tensorflow/tensorboard/tensorboard.
py --logdir /event_log_dir/ --port 8888
WARNING:tensorflow:Found more than one graph event per run.Overwritting the
graph with the newest event
Access Using Browser
Tensorflow Graph
Enhance visualization with scope, names
Tensorflow Graph
Tensorflow Graph: Expanded
Importance of Visualization:
Have we found a good fit?
Linear Regression with 1-Feature
W ~ 2.0b ~ 0.0
Cost reaches zero = good model fit
Training Linear Regression with b > 0
# Generate fake data for y = 2.x + 10, i.e., W = 2, b = 10
all_xs = []
all_ys = []
for i in range(datapoint_size):
# Create fake data for y = W.x + b where W = 2, b = 10
all_xs.append(i)
all_ys.append(2*i+10)
0
1
2
3
.
.
.
.
.
.
99
0
12
14
16
.
.
.
.
.
.
208
all_xs
(house size)
all_ys (house
price)
Linear Regression with 1-Feature (b > 0)
Cost appears to reaches zero ...
… but not quite
Linear Regression with 1-Feature (b > 0)
b slowly learning … (ideally 10)
Is there a way to learn faster?
● Faster gradient descent learning rate?
● Different model?
● Different cost function?
W ~ 2.0
Batch Size
Stochastic Gradient Descent
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
x
y_
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
Mini-batch Gradient Descent
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
y_1
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_1), (x2, y_2), (x3, y_3)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
x2
x3x1
y_2
y_3
mini_batch = 3
Batch Gradient Descent
TF Graph
Model: y = W.x + b
Cost: tf.reduce_mean(tf.square(y_ - y))
W, b
x
y
Update
Actual Datapoints
y_1
Gradient Descent
Cost
Tweak W’, b’
Reduce Cost for (x, y_1), (x2, y_2), ... (xm, y_m)
Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
x2
x3x1
y_2
y_3
y_m
xm
...
...
Stochastic/Mini-batch/Batch Gradient Descent
x = tf.placeholder(tf.float32, [None, 1])
y_ = tf.placeholder(tf.float32, [None, 1])
...
train_step = tf.train.GradientDescentOptimizer(01).minimize(cost)
xs = ....
ys = ….
feed = { x: xs, y_: ys }
sess.run(train_step, feed_dict=feed)
One feature, house size
One output, house price
ONLY this part is different!
Why Feed train_step, with feed_dict = x, y_
train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
cost = tf.reduce_mean(tf.square(y_-y))
y = tf.matmul(x, W) + b
y_ = tf.placeholder(tf.float32, [None, 1]
x = tf.placeholder(tf.float32, [None, 1]
train_step has dependency on x, y_
Stochastic Gradient Descent
Stochastic Gradient Descent
x = tf.placeholder(tf.float32, [None, 1])
y_ = tf.placeholder(tf.float32, [None, 1])
for i in range(steps):
# Create fake data for y = W.x + b where W = 2, b = 0
xs = np.array([[i]])
ys = np.array([[2*i]])
feed = { x: xs, y_: ys }
sess.run(train_step, feed_dict=feed)
One feature, house size
One output, house price
Provide datapoint for feature, house size each step
Provide datapoint for output, house price, each step
Stochastic Gradient Descent
Mini-batch Gradient Descent
Mini-batch Gradient Descent: x, y_
0
1
2
3
4
5
6
7
8
9
.
.
.
.
.
.
999
0
2
4
6
8
10
12
14
16
18
.
.
.
.
.
.
1998
all_xs all_ys
1000
data
points
Mini-batch Gradient Descent: x, y_
0
1
2
3
4
5
6
7
8
9
.
.
.
.
.
.
999
0
2
4
6
8
10
12
14
16
18
.
.
.
.
.
.
1998
all_xs all_ys
Train step #1Batch size = 5
1000
data
points
Mini-batch Gradient Descent: x, y_
0
1
2
3
4
5
6
7
8
9
.
.
.
.
.
.
999
0
2
4
6
8
10
12
14
16
18
.
.
.
.
.
.
1998
all_xs all_ys
Train step #2
Mini-batch Gradient Descent: x, y_
0
1
2
3
4
5
6
7
8
9
.
.
.
.
.
.
999
0
2
4
6
8
10
12
14
16
18
.
.
.
.
.
.
1998
all_xs all_ys
Train step #35
Mini-batch Gradient Descent: x, y_
0
1
2
3
4
5
6
7
8
9
.
.
.
.
.
.
999
0
2
4
6
8
10
12
14
16
18
.
.
.
.
.
.
1998
all_xs all_ys
Train step #36
Mini-batch Gradient Descent
x = tf.placeholder(tf.float32, [None, 1])
y_ = tf.placeholder(tf.float32, [None, 1]")
# Prepare all actual house size (x), house price (y_) before hand
all_xs = ...
all_ys = …
for i in range(steps):
xs = np.array(all_xs[batch_start_idx:batch_end_idx])
ys = np.array(all_ys[batch_start_idx:batch_end_idx])
feed = { x: xs, y_: ys }
sess.run(train_step, feed_dict=feed)
One feature, house size
One output, house price
Code to do data batching
}
Mini-batch Gradient Descent
x = tf.placeholder(tf.float32, [None, 1], name="x-input")
y_ = tf.placeholder(tf.float32, [None, 1], name="y-input")
# Prepare all actual house size (x), house price (y_) before hand
all_xs = ...
all_ys = …
for i in range(steps):
xs = np.array(all_xs[batch_start_idx:batch_end_idx])
ys = np.array(all_ys[batch_start_idx:batch_end_idx])
feed = { x: xs, y_: ys }
sess.run(train_step, feed_dict=feed)
One feature, house size
One output, house price
‘None’ in placeholder means determined at run-time
Code to do data batching
}
Batch Gradient Descent
Batch Gradient Descent: x, y_
0
1
2
3
4
5
6
7
8
9
.
.
.
.
.
.
999
0
2
4
6
8
10
12
14
16
18
.
.
.
.
.
.
1998
all_xs all_ys
Train step #1
Batch Gradient Descent: x, y_
0
1
2
3
4
5
6
7
8
9
.
.
.
.
.
.
999
0
2
4
6
8
10
12
14
16
18
.
.
.
.
.
.
1998
all_xs all_ys
Train step #2
Batch Gradient Descent: x, y_
0
1
2
3
4
5
6
7
8
9
.
.
.
.
.
.
999
0
2
4
6
8
10
12
14
16
18
.
.
.
.
.
.
1998
all_xs all_ys
Train step #N
Batch Gradient Descent
x = tf.placeholder(tf.float32, [None, 1], name="x-input")
y_ = tf.placeholder(tf.float32, [None, 1], name="y-input")
# Prepare all actual house size (x), house price (y_) before hand
all_xs = ...
all_ys = …
for i in range(steps):
xs = all_xs
ys = all_ys
feed = { x: xs, y_: ys }
sess.run(train_step, feed_dict=feed)
One feature, house size
One output, house price
What is the Significance of Batch Size?
Find steepest gradient descent (train_step) from the
viewpoint of the points in the batch
[Batch Size 1] [Batch Size 100] [Full Batch]
Less More
Resource to train each step
Outcome: With same Gradient Descent learning rate ...
Batch Size = 1, Train Steps = 1000
Cost still decreasing towards 0
Still learning ... Still learning ...
Batch Size = 100, Train Steps = 1000
Cost close to 0 = good model fit
W ~ 2.0b ~ 0.0
Batch Size = 1000 (Full), Train Steps = 1000
W ~ 2.0b ~ 0.0
Cost close to 0 = good model fit
[Batch Size 1] [Batch Size 100] [Full Batch]
Less More
Resource to train each step
FewMany
Steps to reach good W, b values
References
Code:
● Using Tensorboard for visualization:
○ https://github.
com/nethsix/gentle_tensorflow/blob/master/code/linear_regression_one_feature_with_tensorb
oard.py
● Performing stochastic/mini-batch/batch Gradient Descent using Tensorflow
○ https://github.
com/nethsix/gentle_tensorflow/blob/master/code/linear_regression_one_feature_using_mini_b
atch_with_tensorboard.py

More Related Content

What's hot

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 itRobert John
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to TensorflowTzar Umang
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPaulo Sergio Lemes Queiroz
 
Tensor board
Tensor boardTensor board
Tensor boardSung Kim
 
Additive model and boosting tree
Additive model and boosting treeAdditive model and boosting tree
Additive model and boosting treeDong Guo
 
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...Lviv Startup Club
 
Pybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in PythonPybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in PythonChristoph Matthies
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
 
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 #3Jay Coskey
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
 
Introduction to TensorFlow, by Machine Learning at Berkeley
Introduction to TensorFlow, by Machine Learning at BerkeleyIntroduction to TensorFlow, by Machine Learning at Berkeley
Introduction to TensorFlow, by Machine Learning at BerkeleyTed Xiao
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasOswald Campesato
 
(2015 06-16) Three Approaches to Monads
(2015 06-16) Three Approaches to Monads(2015 06-16) Three Approaches to Monads
(2015 06-16) Three Approaches to MonadsLawrence Evans
 
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 flowDevatanu Banerjee
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用Mark Chang
 

What's hot (20)

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
 
About RNN
About RNNAbout RNN
About RNN
 
About RNN
About RNNAbout RNN
About RNN
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to Tensorflow
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPU
 
Tensor board
Tensor boardTensor board
Tensor board
 
Python book
Python bookPython book
Python book
 
Additive model and boosting tree
Additive model and boosting treeAdditive model and boosting tree
Additive model and boosting tree
 
Econometrics Notes
Econometrics NotesEconometrics Notes
Econometrics Notes
 
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
 
Pybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in PythonPybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in Python
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
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
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
Introduction to TensorFlow, by Machine Learning at Berkeley
Introduction to TensorFlow, by Machine Learning at BerkeleyIntroduction to TensorFlow, by Machine Learning at Berkeley
Introduction to TensorFlow, by Machine Learning at Berkeley
 
深層学習後半
深層学習後半深層学習後半
深層学習後半
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
 
(2015 06-16) Three Approaches to Monads
(2015 06-16) Three Approaches to Monads(2015 06-16) Three Approaches to Monads
(2015 06-16) Three Approaches to Monads
 
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
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用
 

Viewers also liked

Large Scale Deep Learning with TensorFlow
Large Scale Deep Learning with TensorFlow Large Scale Deep Learning with TensorFlow
Large Scale Deep Learning with TensorFlow Jen Aman
 
RMSLE cost function
RMSLE cost functionRMSLE cost function
RMSLE cost functionKhor SoonHin
 
Tokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJS
Tokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJSTokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJS
Tokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJSKhor SoonHin
 
From Back to Front: Rails To React Family
From Back to Front: Rails To React FamilyFrom Back to Front: Rails To React Family
From Back to Front: Rails To React FamilyKhor SoonHin
 
Electricity price forecasting with Recurrent Neural Networks
Electricity price forecasting with Recurrent Neural NetworksElectricity price forecasting with Recurrent Neural Networks
Electricity price forecasting with Recurrent Neural NetworksTaegyun Jeon
 
Machine learning and TensorFlow
Machine learning and TensorFlowMachine learning and TensorFlow
Machine learning and TensorFlowJose Papo, MSc
 
Tokyo React.js #3 Meetup (ja): Missing Pages: ReactJS/GraphQL/RelayJS
Tokyo React.js #3 Meetup (ja): Missing Pages: ReactJS/GraphQL/RelayJSTokyo React.js #3 Meetup (ja): Missing Pages: ReactJS/GraphQL/RelayJS
Tokyo React.js #3 Meetup (ja): Missing Pages: ReactJS/GraphQL/RelayJSKhor SoonHin
 
Tensorflow internal
Tensorflow internalTensorflow internal
Tensorflow internalHyunghun Cho
 
Neural Networks with Google TensorFlow
Neural Networks with Google TensorFlowNeural Networks with Google TensorFlow
Neural Networks with Google TensorFlowDarshan Patel
 
Detecting Hacks: Anomaly Detection on Networking Data
Detecting Hacks: Anomaly Detection on Networking DataDetecting Hacks: Anomaly Detection on Networking Data
Detecting Hacks: Anomaly Detection on Networking DataDataWorks Summit
 
Anomaly Detection using Spark MLlib and Spark Streaming
Anomaly Detection using Spark MLlib and Spark StreamingAnomaly Detection using Spark MLlib and Spark Streaming
Anomaly Detection using Spark MLlib and Spark StreamingKeira Zhou
 
Anomaly Detection with Apache Spark
Anomaly Detection with Apache SparkAnomaly Detection with Apache Spark
Anomaly Detection with Apache SparkCloudera, Inc.
 
Neural Networks, Spark MLlib, Deep Learning
Neural Networks, Spark MLlib, Deep LearningNeural Networks, Spark MLlib, Deep Learning
Neural Networks, Spark MLlib, Deep LearningAsim Jalis
 
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...Big Data Spain
 
TensorFlow 深度學習講座
TensorFlow 深度學習講座TensorFlow 深度學習講座
TensorFlow 深度學習講座Mark Chang
 
Introduction to Deep Learning with TensorFlow
Introduction to Deep Learning with TensorFlowIntroduction to Deep Learning with TensorFlow
Introduction to Deep Learning with TensorFlowTerry Taewoong Um
 
TensorFlow White Paperを読む
TensorFlow White Paperを読むTensorFlow White Paperを読む
TensorFlow White Paperを読むYuta Kashino
 

Viewers also liked (20)

TensorFlow
TensorFlowTensorFlow
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
 
Rails + Webpack
Rails + WebpackRails + Webpack
Rails + Webpack
 
RMSLE cost function
RMSLE cost functionRMSLE cost function
RMSLE cost function
 
Tokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJS
Tokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJSTokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJS
Tokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJS
 
From Back to Front: Rails To React Family
From Back to Front: Rails To React FamilyFrom Back to Front: Rails To React Family
From Back to Front: Rails To React Family
 
Electricity price forecasting with Recurrent Neural Networks
Electricity price forecasting with Recurrent Neural NetworksElectricity price forecasting with Recurrent Neural Networks
Electricity price forecasting with Recurrent Neural Networks
 
Machine learning and TensorFlow
Machine learning and TensorFlowMachine learning and TensorFlow
Machine learning and TensorFlow
 
Tokyo React.js #3 Meetup (ja): Missing Pages: ReactJS/GraphQL/RelayJS
Tokyo React.js #3 Meetup (ja): Missing Pages: ReactJS/GraphQL/RelayJSTokyo React.js #3 Meetup (ja): Missing Pages: ReactJS/GraphQL/RelayJS
Tokyo React.js #3 Meetup (ja): Missing Pages: ReactJS/GraphQL/RelayJS
 
Tensorflow internal
Tensorflow internalTensorflow internal
Tensorflow internal
 
Neural Networks with Google TensorFlow
Neural Networks with Google TensorFlowNeural Networks with Google TensorFlow
Neural Networks with Google TensorFlow
 
Detecting Hacks: Anomaly Detection on Networking Data
Detecting Hacks: Anomaly Detection on Networking DataDetecting Hacks: Anomaly Detection on Networking Data
Detecting Hacks: Anomaly Detection on Networking Data
 
Anomaly Detection using Spark MLlib and Spark Streaming
Anomaly Detection using Spark MLlib and Spark StreamingAnomaly Detection using Spark MLlib and Spark Streaming
Anomaly Detection using Spark MLlib and Spark Streaming
 
Anomaly Detection with Apache Spark
Anomaly Detection with Apache SparkAnomaly Detection with Apache Spark
Anomaly Detection with Apache Spark
 
Neural Networks, Spark MLlib, Deep Learning
Neural Networks, Spark MLlib, Deep LearningNeural Networks, Spark MLlib, Deep Learning
Neural Networks, Spark MLlib, Deep Learning
 
Tensorflow 2
Tensorflow 2Tensorflow 2
Tensorflow 2
 
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
 
TensorFlow 深度學習講座
TensorFlow 深度學習講座TensorFlow 深度學習講座
TensorFlow 深度學習講座
 
Introduction to Deep Learning with TensorFlow
Introduction to Deep Learning with TensorFlowIntroduction to Deep Learning with TensorFlow
Introduction to Deep Learning with TensorFlow
 
TensorFlow White Paperを読む
TensorFlow White Paperを読むTensorFlow White Paperを読む
TensorFlow White Paperを読む
 

Similar to Tensorflow Intro Part 2

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.docxlauracallander
 
Neural networks with python
Neural networks with pythonNeural networks with python
Neural networks with pythonSimone Piunno
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
 
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...Codemotion
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type ClassesTapio Rautonen
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITiansAshish Bansal
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
 
Testing in the World of Functional Programming
Testing in the World of Functional ProgrammingTesting in the World of Functional Programming
Testing in the World of Functional ProgrammingLuka Jacobowitz
 
Introducton to Convolutional Nerural Network with TensorFlow
Introducton to Convolutional Nerural Network with TensorFlowIntroducton to Convolutional Nerural Network with TensorFlow
Introducton to Convolutional Nerural Network with TensorFlowEtsuji Nakai
 
Visual Basic(Vb) practical
Visual Basic(Vb) practicalVisual Basic(Vb) practical
Visual Basic(Vb) practicalRahul juneja
 
Effective way to code in Scala
Effective way to code in ScalaEffective way to code in Scala
Effective way to code in ScalaKnoldus Inc.
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions Dr. Volkan OBAN
 
DF1 - Py - Ovcharenko - Theano Tutorial
DF1 - Py - Ovcharenko - Theano TutorialDF1 - Py - Ovcharenko - Theano Tutorial
DF1 - Py - Ovcharenko - Theano TutorialMoscowDataFest
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
CS229 Machine Learning Lecture Notes
CS229 Machine Learning Lecture NotesCS229 Machine Learning Lecture Notes
CS229 Machine Learning Lecture NotesEric Conner
 

Similar to Tensorflow Intro Part 2 (20)

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
 
Neural networks with python
Neural networks with pythonNeural networks with python
Neural networks with python
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
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...
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type Classes
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITians
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Testing in the World of Functional Programming
Testing in the World of Functional ProgrammingTesting in the World of Functional Programming
Testing in the World of Functional Programming
 
Introducton to Convolutional Nerural Network with TensorFlow
Introducton to Convolutional Nerural Network with TensorFlowIntroducton to Convolutional Nerural Network with TensorFlow
Introducton to Convolutional Nerural Network with TensorFlow
 
Função afim resumo teórico e exercícios - celso brasil
Função afim   resumo teórico e exercícios - celso brasilFunção afim   resumo teórico e exercícios - celso brasil
Função afim resumo teórico e exercícios - celso brasil
 
Visual Basic(Vb) practical
Visual Basic(Vb) practicalVisual Basic(Vb) practical
Visual Basic(Vb) practical
 
Effective way to code in Scala
Effective way to code in ScalaEffective way to code in Scala
Effective way to code in Scala
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 
DF1 - Py - Ovcharenko - Theano Tutorial
DF1 - Py - Ovcharenko - Theano TutorialDF1 - Py - Ovcharenko - Theano Tutorial
DF1 - Py - Ovcharenko - Theano Tutorial
 
Gonzalez, rafael,c.digitalimageprocessingusing matlab
Gonzalez, rafael,c.digitalimageprocessingusing matlabGonzalez, rafael,c.digitalimageprocessingusing matlab
Gonzalez, rafael,c.digitalimageprocessingusing matlab
 
TensorFlow Tutorial.pdf
TensorFlow Tutorial.pdfTensorFlow Tutorial.pdf
TensorFlow Tutorial.pdf
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
CS229 Machine Learning Lecture Notes
CS229 Machine Learning Lecture NotesCS229 Machine Learning Lecture Notes
CS229 Machine Learning Lecture Notes
 

Recently uploaded

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Tensorflow Intro Part 2

  • 1. Gentlest Intro to Tensorflow (Part 2) Khor Soon Hin, @neth_6, re:Culture In collaboration with Sam & Edmund
  • 2. Next Steps ● Review of Tensorflow ○ In illustrations ○ tf.placeholder & feed ○ Training process ● Tensorboard: Visualize cost, W, b ● Training batch size: Stochastic/Mini-batch/Full-batch
  • 3. Quick Review Given house size, use machine learning to predict house price
  • 4. Quick Review House Size, sqm House Price, $
  • 5. Quick Review House Size, sqm House Price, $ Collect (‘generate fake’) data y (house price) = 2.x (house size)
  • 6. Quick Review House Size, sqm House Price, $ Model using linear regression y = W.x + b
  • 7. Quick Review House Size, sqm House Price, $ Model using linear regression y = W.x + b Learn the best W, b
  • 8. Quick Review House Size, sqm House Price, $ Model using linear regression y = W.x + b Learn the best W, b by reducing cost
  • 9. Quick Review House Size, sqm House Price, $ Model using linear regression y = W.x + b Best W, b helps make best predictionPrediction! Any house size!
  • 10. Quick Review Modeling linear regression in Tensorflow
  • 11. Tensorflow Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y))
  • 12. Tensorflow Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) prediction
  • 13. Tensorflow Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) Goal: Trainprediction
  • 14. Tensorflow Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) Goal: Train How: Minimizing actual vs. prediction prediction
  • 15. Tensorflow Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) Goal: Train How: Minimizing actual vs. prediction prediction Train: tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
  • 16. W, b Init with some values What is Train?
  • 17. What is Train? TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b Init with some values
  • 18. What is Train? TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Init with some values Actual Datapoints x y_
  • 19. What is Train? TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Init with some values Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
  • 20. What is Train? TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
  • 21. What is Train? TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) One training step Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
  • 22. What is Train? TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
  • 23. What is Train? TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
  • 24. What is Train? TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Train: tf.train.GradientDescentOptimizer(01).minimize(cost) Repeat N steps OR Until Cost reaches desired value
  • 26. Tensorflow Graph TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Train: tf.train.GradientDescentOptimizer(01).minimize(cost) Model in TF!
  • 27. Tensorflow Graph TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Define as tf.Variable Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
  • 28. Tensorflow Graph TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Define as tf.placeholder Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
  • 29. Tensorflow Graph: tf.Variable (Enhance visualization) # tf.Variable for holding variables we want to learn, W, b W = tf.Variable(tf.zeros([1,1]), name=‘W’) b = tf.Variable(tf.zeros([1]), name=‘b’) NOTE: Without name=XXX, the variables will be assigned names like Variable_0, Variable_1, etc. 1 feature, house size 1 output, house price
  • 30. Tensorflow Graph: tf.placeholder (Enhance visualization) # tf.placeholder for actual data, e.g., house size (x), house price (y_) x = tf.placeholder(tf.float32, [None, 1], name=‘x’) y_ = tf.placeholder(tf.float32, [None, 1], name=‘y_’) NOTE: Without name=XXX, the placeholders will be assigned names like Placeholder_0, Placeholder_1, etc. 1 feature, house size 1 output, house price
  • 31. Tensorflow Graph: Model (Enhance visualization) # Model linear regression y = Wx + b with tf.name_scope("Wx_b") as scope: product = tf.matmul(x,W) y = product + b NOTE: With scope, the all definitions under it, will appear as a black-box that is expandable!
  • 32. Tensorflow Graph: Cost (Enhance visualization) # Cost function: Least-squared difference with tf.name_scope("cost") as scope: cost = tf.reduce_mean(tf.square(y_-y))
  • 33. Tensorflow Graph: Train (Enhance visualization) # Train step with tf.name_scope("train") as scope: train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
  • 35. Two Main Components ● Summary ○ Mark data we want to collect ■ W, b, cost ● Writer ○ Write data collected to event file
  • 36. Tensorflow Summary: Scalar tf.scalar_summary # cost is single-dimension so # mark it as data to be collected using scalar_summary cost = tf.reduce_mean(tf.square(y_-y)) cost_sum = tf.scalar_summary("cost", cost)
  • 37. Tensorflow Summary: Histogram tf.histogram_summary # W and b can be multi-dimensional so # mark them as data to be collected using histogram_summary W = tf.Variable(tf.zeros([1,1]), name="W") W_hist = tf.histogram_summary("weights", W) b = tf.Variable(tf.zeros([1]), name="b") b_hist = tf.histogram_summary("biases", b)
  • 38. Tensorflow Summary: Merge tf.merge_all_summaries merged = tf.merge_all_summaries() tf.merge_summary merged = tf.merge_summary([W_hist, b_hist, cost_sum])
  • 39. Tensorflow Writer # The specified log directory will be: # * Created if it does not exist # * If exist and not empty data is merged # sess.graph_def will enable Tensorflow to draw graph representation # for network writer = tf.train.SummaryWriter("/event_log_dir", sess.graph_def)
  • 40. Tensorflow Writer: When to Record Data # NOTE: Train using #steps for i in steps: ... # NOTE: Write summary every 10 samples if i % 10 == 0: all_feed = { x: all_xs, y_: all_ys } # NOTE: # * merged is our merged summary name # * feed is the batch of all x, y data points, to calculate TOTAL cost result = sess.run(merged, feed_dict=all_feed) writer.add_summary(result, i) ...
  • 41. Start Tensorboard Server NOTE: Single line python /usr/local/lib/python2.7/dist-packages/tensorflow/tensorboard/tensorboard. py --logdir /event_log_dir/ --port 8888 WARNING:tensorflow:Found more than one graph event per run.Overwritting the graph with the newest event
  • 46. Importance of Visualization: Have we found a good fit?
  • 47. Linear Regression with 1-Feature W ~ 2.0b ~ 0.0 Cost reaches zero = good model fit
  • 48. Training Linear Regression with b > 0 # Generate fake data for y = 2.x + 10, i.e., W = 2, b = 10 all_xs = [] all_ys = [] for i in range(datapoint_size): # Create fake data for y = W.x + b where W = 2, b = 10 all_xs.append(i) all_ys.append(2*i+10) 0 1 2 3 . . . . . . 99 0 12 14 16 . . . . . . 208 all_xs (house size) all_ys (house price)
  • 49. Linear Regression with 1-Feature (b > 0) Cost appears to reaches zero ... … but not quite
  • 50. Linear Regression with 1-Feature (b > 0) b slowly learning … (ideally 10) Is there a way to learn faster? ● Faster gradient descent learning rate? ● Different model? ● Different cost function? W ~ 2.0
  • 52. Stochastic Gradient Descent TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints x y_ Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_) Train: tf.train.GradientDescentOptimizer(01).minimize(cost)
  • 53. Mini-batch Gradient Descent TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints y_1 Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_1), (x2, y_2), (x3, y_3) Train: tf.train.GradientDescentOptimizer(01).minimize(cost) x2 x3x1 y_2 y_3 mini_batch = 3
  • 54. Batch Gradient Descent TF Graph Model: y = W.x + b Cost: tf.reduce_mean(tf.square(y_ - y)) W, b x y Update Actual Datapoints y_1 Gradient Descent Cost Tweak W’, b’ Reduce Cost for (x, y_1), (x2, y_2), ... (xm, y_m) Train: tf.train.GradientDescentOptimizer(01).minimize(cost) x2 x3x1 y_2 y_3 y_m xm ... ...
  • 55. Stochastic/Mini-batch/Batch Gradient Descent x = tf.placeholder(tf.float32, [None, 1]) y_ = tf.placeholder(tf.float32, [None, 1]) ... train_step = tf.train.GradientDescentOptimizer(01).minimize(cost) xs = .... ys = …. feed = { x: xs, y_: ys } sess.run(train_step, feed_dict=feed) One feature, house size One output, house price ONLY this part is different!
  • 56. Why Feed train_step, with feed_dict = x, y_ train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost) cost = tf.reduce_mean(tf.square(y_-y)) y = tf.matmul(x, W) + b y_ = tf.placeholder(tf.float32, [None, 1] x = tf.placeholder(tf.float32, [None, 1] train_step has dependency on x, y_
  • 58. Stochastic Gradient Descent x = tf.placeholder(tf.float32, [None, 1]) y_ = tf.placeholder(tf.float32, [None, 1]) for i in range(steps): # Create fake data for y = W.x + b where W = 2, b = 0 xs = np.array([[i]]) ys = np.array([[2*i]]) feed = { x: xs, y_: ys } sess.run(train_step, feed_dict=feed) One feature, house size One output, house price Provide datapoint for feature, house size each step Provide datapoint for output, house price, each step Stochastic Gradient Descent
  • 60. Mini-batch Gradient Descent: x, y_ 0 1 2 3 4 5 6 7 8 9 . . . . . . 999 0 2 4 6 8 10 12 14 16 18 . . . . . . 1998 all_xs all_ys 1000 data points
  • 61. Mini-batch Gradient Descent: x, y_ 0 1 2 3 4 5 6 7 8 9 . . . . . . 999 0 2 4 6 8 10 12 14 16 18 . . . . . . 1998 all_xs all_ys Train step #1Batch size = 5 1000 data points
  • 62. Mini-batch Gradient Descent: x, y_ 0 1 2 3 4 5 6 7 8 9 . . . . . . 999 0 2 4 6 8 10 12 14 16 18 . . . . . . 1998 all_xs all_ys Train step #2
  • 63. Mini-batch Gradient Descent: x, y_ 0 1 2 3 4 5 6 7 8 9 . . . . . . 999 0 2 4 6 8 10 12 14 16 18 . . . . . . 1998 all_xs all_ys Train step #35
  • 64. Mini-batch Gradient Descent: x, y_ 0 1 2 3 4 5 6 7 8 9 . . . . . . 999 0 2 4 6 8 10 12 14 16 18 . . . . . . 1998 all_xs all_ys Train step #36
  • 65. Mini-batch Gradient Descent x = tf.placeholder(tf.float32, [None, 1]) y_ = tf.placeholder(tf.float32, [None, 1]") # Prepare all actual house size (x), house price (y_) before hand all_xs = ... all_ys = … for i in range(steps): xs = np.array(all_xs[batch_start_idx:batch_end_idx]) ys = np.array(all_ys[batch_start_idx:batch_end_idx]) feed = { x: xs, y_: ys } sess.run(train_step, feed_dict=feed) One feature, house size One output, house price Code to do data batching }
  • 66. Mini-batch Gradient Descent x = tf.placeholder(tf.float32, [None, 1], name="x-input") y_ = tf.placeholder(tf.float32, [None, 1], name="y-input") # Prepare all actual house size (x), house price (y_) before hand all_xs = ... all_ys = … for i in range(steps): xs = np.array(all_xs[batch_start_idx:batch_end_idx]) ys = np.array(all_ys[batch_start_idx:batch_end_idx]) feed = { x: xs, y_: ys } sess.run(train_step, feed_dict=feed) One feature, house size One output, house price ‘None’ in placeholder means determined at run-time Code to do data batching }
  • 68. Batch Gradient Descent: x, y_ 0 1 2 3 4 5 6 7 8 9 . . . . . . 999 0 2 4 6 8 10 12 14 16 18 . . . . . . 1998 all_xs all_ys Train step #1
  • 69. Batch Gradient Descent: x, y_ 0 1 2 3 4 5 6 7 8 9 . . . . . . 999 0 2 4 6 8 10 12 14 16 18 . . . . . . 1998 all_xs all_ys Train step #2
  • 70. Batch Gradient Descent: x, y_ 0 1 2 3 4 5 6 7 8 9 . . . . . . 999 0 2 4 6 8 10 12 14 16 18 . . . . . . 1998 all_xs all_ys Train step #N
  • 71. Batch Gradient Descent x = tf.placeholder(tf.float32, [None, 1], name="x-input") y_ = tf.placeholder(tf.float32, [None, 1], name="y-input") # Prepare all actual house size (x), house price (y_) before hand all_xs = ... all_ys = … for i in range(steps): xs = all_xs ys = all_ys feed = { x: xs, y_: ys } sess.run(train_step, feed_dict=feed) One feature, house size One output, house price
  • 72. What is the Significance of Batch Size? Find steepest gradient descent (train_step) from the viewpoint of the points in the batch
  • 73. [Batch Size 1] [Batch Size 100] [Full Batch] Less More Resource to train each step
  • 74. Outcome: With same Gradient Descent learning rate ...
  • 75. Batch Size = 1, Train Steps = 1000 Cost still decreasing towards 0 Still learning ... Still learning ...
  • 76. Batch Size = 100, Train Steps = 1000 Cost close to 0 = good model fit W ~ 2.0b ~ 0.0
  • 77. Batch Size = 1000 (Full), Train Steps = 1000 W ~ 2.0b ~ 0.0 Cost close to 0 = good model fit
  • 78. [Batch Size 1] [Batch Size 100] [Full Batch] Less More Resource to train each step FewMany Steps to reach good W, b values
  • 79. References Code: ● Using Tensorboard for visualization: ○ https://github. com/nethsix/gentle_tensorflow/blob/master/code/linear_regression_one_feature_with_tensorb oard.py ● Performing stochastic/mini-batch/batch Gradient Descent using Tensorflow ○ https://github. com/nethsix/gentle_tensorflow/blob/master/code/linear_regression_one_feature_using_mini_b atch_with_tensorboard.py