Introduction to Machine Learning with TensorFlow
-
Upload
paolo-tomeo -
Category
Data & Analytics
-
view
552 -
download
0
Transcript of Introduction to Machine Learning with TensorFlow
![Page 1: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/1.jpg)
Introduction to Machine Learning with TensorFlow
Paolo Tomeo
![Page 2: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/2.jpg)
Open source Machine Learning library
Especially useful for Deep Learning
For research and production
Apache 2.0 license
![Page 3: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/3.jpg)
Machine LearningComputer algorithms for learning to do something
- learning to complete a task- make accurate predictions- to behave intelligently
The focus is on automatic methods: learning without any human intervention
![Page 4: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/4.jpg)
Hello World
Image from https://github.com/mnielsen/neural-networks-and-deep-learning
?
![Page 5: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/5.jpg)
What we see What the computer “sees”
![Page 6: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/6.jpg)
Complete code
import tensorflow as tf
mnist = tf.contrib.learn.datasets.load_dataset('mnist')
classifier = tf.learn.LinearClassifier(n_classes=10)
classifier.fit(mnist.train.images, mnist.train.labels)
score = metrics.accuracy_score(mnist.test.labels,
classifier.predict(mnist.test.images))
print('Accuracy: {0:f}'.format(score))
![Page 7: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/7.jpg)
![Page 8: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/8.jpg)
Biologically Inspired Artificial Neural Network
Image from https://visualstudiomagazine.com/articles/2014/06/01/deep-neural-networks.aspx
![Page 9: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/9.jpg)
Deep Neural Network (DNN)
![Page 10: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/10.jpg)
Iris Dataset
![Page 11: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/11.jpg)
Deep Learning Classifier for Iris Dataset (1/3)
Tutorial from https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html#tf-contrib-learn-quickstart
import tensorflow as tfimport numpy as np
# Data setsIRIS_TRAINING = "iris_training.csv“IRIS_TEST = "iris_test.csv"
# Load datasets.training_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TRAINING,
target_dtype=np.int)
test_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TEST,
target_dtype=np.int)
![Page 12: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/12.jpg)
Deep Learning Classifier for Iris Dataset (2/3)
Tutorial from https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html#tf-contrib-learn-quickstart
# Specify that all features have real-value datafeature_columns = [tf.contrib.layers.real_valued_column("", dimension=4)]
# Build 3 layer DNN with 10, 20, 10 units respectively.classifier = tf.contrib.learn.DNNClassifier(feature_columns=feature_columns, hidden_units=[10, 20, 10],
n_classes=3,model_dir="/tmp/iris_model")
# Fit model.classifier.fit(x=training_set.data, y=training_set.target,
steps=2000)
![Page 13: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/13.jpg)
Deep Learning Classifier for Iris Dataset (3/3)
Tutorial from https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html#tf-contrib-learn-quickstart
# Evaluate accuracy.accuracy_score = classifier.evaluate(x=test_set.data, y=test_set.target)["accuracy"]
print('Accuracy: {0:f}'.format(accuracy_score))
# Classify two new flower samples.new_samples = np.array([[6.4, 3.2, 4.5, 1.5], [5.8, 3.1, 5.0, 1.7]], dtype=float)
y = classifier.predict(new_samples)
print('Predictions: {}'.format(str(y)))
![Page 14: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/14.jpg)
Getting Started Exercises
![Page 16: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/16.jpg)
Codelab - goo.gl/xGsB9d Video - goo.gl/B2zYWN
TensorFlow for Poets
![Page 17: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/17.jpg)
Mobile TensorFlow
![Page 18: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/18.jpg)
Claude Monet - Bouquet of SunflowersImages from the Metropolitan Museum of Art (with permission) Image by @random_forests
![Page 19: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/19.jpg)
A little more TensorFlow
![Page 20: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/20.jpg)
A multidimensional array.
A graph of operations.
![Page 21: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/21.jpg)
Data Flow Graphs
Computation is defined as a directed acyclic graph (DAG) to optimize an objective function
Graph is defined in high-level language (Python)
Graph is compiled and optimized
Graph is executed (in parts or fully) on available low level devices (CPU, GPU)
Data (tensors) flow through the graph
TensorFlow can compute gradients automatically
![Page 22: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/22.jpg)
ArchitectureCore in C++
Front ends: Python and C++ today, community may add more
Core TensorFlow Execution System
CPU GPU Android iOS ...
C++ front end Python front end ...
![Page 23: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/23.jpg)
tf.contrib.learn
TensorFlow’s high-level machine learning API
Easy to configure, train, and evaluate a variety of machine learning models
Datasets available in tf.contrib.learn.datasets
Warning: any code in tf.contrib is not officially supported, and may change or be removed at any time without notice.
![Page 24: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/24.jpg)
tf.contrib.learn
TensorFlow’s high-level machine learning API
Easy to configure, train, and evaluate a variety of machine learning models
Datasets available in tf.contrib.learn.datasets
Warning: any code in tf.contrib is not officially supported, and may change or be removed at any time without notice.
![Page 25: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/25.jpg)
Questions?
![Page 26: Introduction to Machine Learning with TensorFlow](https://reader035.fdocuments.us/reader035/viewer/2022062302/58f9a947760da3da068b6d03/html5/thumbnails/26.jpg)
tensorflow.orggithub.com/tensorflow
Want to learn more?Udacity class on Deep Learning, goo.gl/iHssII
Guides, codelabs, videosMNIST for Beginners, goo.gl/tx8R2bTF Learn Quickstart, goo.gl/uiefRnTensorFlow for Poets, goo.gl/bVjFILML Recipes, goo.gl/KewA03TensorFlow and Deep Learning without a PhD, goo.gl/pHeXe7
What's Next