The document introduces TensorFlow, a machine learning library. It discusses how TensorFlow uses multi-dimensional arrays called tensors to represent data and models. An example regression problem is demonstrated where TensorFlow is used to fit a line to sample data points by iteratively updating the slope and offset values to minimize loss. The document promotes TensorFlow by noting its ability to distribute operations across processors and optimize entire graphs.
3. What is Machine Learning?
usually: Statistical Pattern Matching
Using past measurements to predict something
about a new piece of information
4. Does this picture contain a cat? Classification
How much is this home worth? Regression
Regression Talk
https://docs.google.com/presentation/d/17FoojZ17DKDZqoByhB16PmtAXtnJ
tXSy1-feK9-A_fg/edit#slide=id.p10
6. Is it right for you?
Maybe Not, use Prediction API
http://www.slideshare.net/gabehamilton/intro-to-google-prediction-api-15167420
Or equivalent Amazon or Microsoft APIs
if you have a CSV of observed data.
7. But I’d like to get into the
details or I am working on
a complex problem...
8. You do still have some
choices.
Some people prefer Keras on top of TensorFlow
https://keras.io/ or tf-slim or pretty-tensor
9. So why use TensorFlow?
It’s not much different than the “easier” libraries.
You’ll want to understand more and more details anyway.
Because you like
It has the hottest dance moves!
12. For our purposes
It’s a multi-dimensional array.
Just remember that you are
putting a mathematical construct
in that array.
A tensor is a multi-dimensional
array with certain transformation
properties
13. You have some data
Even though it’s in a 2D spreadsheet it can
describe a multidimensional space.
House Price Data
1 mile to park
2 bedrooms
1800 sq ft
So our Tensor is [1, 2, 1800]Square footage
Distance to park
# of bathrooms
19. Demo code: fitting a line to points
Demo is of Datalab notebook
# Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
tf.reset_default_graph()
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x_measured = np.random.rand(100).astype(np.float32)
y_measured = x_measured * (0.1 + (0.05 *np.random.rand(100))) + 0.3
plt.scatter(x_measured, y_measured)
plt.xlabel('<- Bluer : Uniform Color : Redder ->')
plt.ylabel('Deaths per mission')
plt.title('Star Trek Uniform Color Mortality Incidence')
# plt.plot([0, 1], [0, 0.5], color='purple', lw=2)
# plt.plot([0, 1], [0.25, 0.5], color='purple', lw=2)
Measured Data
20. Demo code continued
import tensorflow as tf
# Try to find values for slope and offset that match
# y_measured = slope * x_measured + offset
slope = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
offset = tf.Variable(tf.zeros([1]))
y_predicted = slope * x_measured + offset
loss = tf.reduce_mean(tf.square(y_predicted - y_measured))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)
A test value for slope
21. Demo code continued
# Launch the graph.
sess = tf.Session()
sess.run(tf.initialize_all_variables()) # and initialize variables
# Fit the line.
print 'step #t', 'slopett', 'offset'
for step in range(201):
sess.run(train)
if step % 20 == 0:
print step,'t', sess.run(slope)[0], 't', sess.run(offset)[0]
A test value for slope and offset
22. Q & A
Plus more slides for longer talks or
answering questions
23. Why TensorFlow is useful
Build your graph in a high level language,
execute in fast implementations.
Distribute graph operations across processors.
Whole graph can be optimized.
24. 4+ D Spaces
A given measurement all fits into a simple Tensor: [4, 4, 4, 3]