+ All Categories
Home > Documents > ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim ...

ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim ...

Date post: 18-Mar-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
30
Lab 9-1 NN for XOR Sung Kim <[email protected]>
Transcript
Page 1: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Lab 9-1 NN for XOR

Sung Kim <[email protected]>

Page 2: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Data set

Page 3: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

XOR with logistic regression?

Page 4: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

XOR with logistic regression?

Page 5: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Does not work!

Page 6: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

NN

Page 7: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

NN for XOR

Page 8: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

NN for XOR

Page 9: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Wide NN for XOR

Page 10: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Wide NN for XOR

Page 11: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Deep NN for XOR

Page 12: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Deep NN for XOR

Page 13: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Let’s go deep & wide!

Page 14: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Lab 9-2 Tensorboard

Sung Kim <[email protected]>

Page 15: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

TensorBoard: TF logging/debugging tool

• Visualize your TF graph

• Plot quantitative metrics

• Show additional data

https://www.tensorflow.org/versions/r0.7/how_tos/summaries_and_tensorboard/index.html

Page 16: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Old fashion

Page 17: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

New way!

Page 18: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

5 steps of using tensorboard

• From TF graph, decide which node you want to annotate- with tf.name_scope("test") as scope:

- tf.histogram_summary("weights", W), tf.scalar_summary(“accuracy", accuracy)

• Merge all summaries- merged = tf.merge_all_summaries()

• Create writer- writer = tf.train.SummaryWriter("/tmp/mnist_logs", sess.graph_def)

• Run summary merge and add_summary- summary = sess.run(merged, …); writer.add_summary(summary);

• Launch Tensorboard- tensorboard --logdir=/tmp/mnist_logs

Page 19: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Name variables

Page 20: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Add scope for better graph hierarch

Page 21: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Add histogram

Page 22: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Add scalar variables

Page 23: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

merge summaries and create writer after creating session

Page 24: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Run merged summary and write (add summary)

Page 25: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Launch tensorboard

• tensorboard —logdir=/tmp/mnist_logs

• (You can navigate to http://0.0.0.0:6006)

Page 26: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Add scope for better graph hierarch

Page 27: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Add scope for better graph hierarch

Page 28: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Add histogram

Page 29: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

Add scalar variables

Page 30: ML with Tensorflow labhunkim.github.io/ml/lab9.pdf · 2017-10-02 · Lab 9-1 NN for XOR Sung Kim  Data set. XOR with logistic regression? XOR with logistic

5 steps of using tensorboard

• From TF graph, decide which node you want to annotate- with tf.name_scope("test") as scope:

- tf.histogram_summary("weights", W), tf.scalar_summary(“accuracy", accuracy)

• Merge all summaries- merged = tf.merge_all_summaries()

• Create writer- writer = tf.train.SummaryWriter("/tmp/mnist_logs", sess.graph_def)

• Run summary merge and add_summary- summary = sess.run(merged, …); writer.add_summary(summary);

• Launch Tensorboard- tensorboard --logdir=/tmp/mnist_logs


Recommended